UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-19 20:31:24";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 00:01:24", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 00:01:24', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-19 20:31:36";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 00:01:36", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 00:01:36', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-19 20:34:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 00:04:27", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 00:04:27', '9', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=add');
BEGIN;
INSERT INTO transfermoney (saveidfrom, saveidto, transfermoneyvalue, transfermoneydate, userid, conditions, dailyentryid , comment,currencyId,conversionFactor,conversionFactorFrom,conversionFactorTo,transfermoneyvalueInCurrency) VALUES ('1','4', '63850', '2024-12-20', '9', '0', '0','','1','1','0','0','63850');
UPDATE save SET  savecurrentvalue = '0',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('63850.00','63850', '1', '1', 'تحويل امول الى الخزنة  [ خزنة البيت ] ', '3534', '0', '2024-12-20 00:04:28', '9',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '171515',  userid = '9' WHERE saveid = '4';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('107665.00','63850', '0', '4', 'تحويل امول من الخزنة  [ نقدي ] ', '3534', '171515', '2024-12-20 00:04:28', '9',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '4', transfermoneyvalue = '63850.00', transfermoneydate = '2024-12-20', userid = '9', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='63850' WHERE transfermoneyid = '3534';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-19 20:34:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 00:04:28", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 00:04:28', '9', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-19 20:34:30";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 00:04:30", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 00:04:30', '9', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-19 20:34:38";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 00:04:38", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 00:04:38', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-19 20:34:50";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 00:04:50", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 00:04:50', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-19 20:36:07";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 00:06:07", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 00:06:07', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-19 20:36:16";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 00:06:16", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 00:06:16', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-19 20:36:41";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 00:06:41", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 00:06:41', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-19 20:36:45";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 00:06:45", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 00:06:45', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE programsettings SET companyname = 'BRAVO STORE', address = '8 شارع بورسعيد امام مستشفى السيد جلال', specializtion = 'Shoes ', phone = '01000464376', faxnumber = '0502232923', email = 'mrabozied@gt4it.com', website = 'www.gt4host.com', logo = '7e5a967475936eb131e45001c916f002.jpg', roundnumbers = '0', saveprinting = '0', deptprinting = '0', printingpapersize = '0', userid = '1', showPreviousPrice = '0', parcode = '0', priceing = '0', lastprice = '0', searchvalue = '1',clientsearchvalue = '3', updateproductprice = '0', allowfinsldelete = '0', updateclientprice = '0', `partition` = '0', taxcard = '332', commercialregistration = '3213123312', costcenter = '1', clinic = '1', workshop = '1', transport = '1', manufacturing = '0', masterCopy = '0' , dailyentrydate = '2020-04-18' ,updatefiledate = '2024-12-19',workerbetweenstores = '1',workshoptimeout = '24',drivertimeout = '3',currancy = 'جنيه',serial='7d1e8143a130fbea73dd3b9428a2caad8616ba42c98c2ee7a1bee8768760601b26945ac68358157bd4fc715be3f2049d90617f7a25078b4fb12d780f17ff8d26',allowdateedit = '1', clientcode = '1' ,clientserial = '1',timezone = 'Africa/Cairo' , expiredate ='1' , production ='1' , description='1' , service ='1' , date='1' , limitamount = '1' , measuringunit = '1' , print_amount = '0' , billid = '0' , precentages = '1' , realprice = '1' ,delegate_seller = '0' , storeserial = '1' ,clientfieldrequired ='0' , clientcodname='0' , colortype = '0' , nakdyOnly = '0' , nakdyKashf = '0' , discount_pres_direct = '0' , general_discount = '0' , sells_return = '0' ,scunitname ='0',vatValue = '0.00',syncstructure = '1',showPrevPrices = '0',isOpticProg='1',reportsPlusHours = '2' , showM5zon = '1',restaurantStoreId = '1',restuarantPrintTimeout = '8',sumSameProductForStore = '0', editAllPrice = '1', isCafe = '0' ,isRestaurent = '0' ,productDays = '0',thereIsRestTax = '0',restTaxVal = '0',restPrintLang = '0',taxNameFlag = '0',parcodeDigits = '5' ,specializedParcodeDigits = '7', clientDefaultDebtLimit = '10000' , clientDefaultDebtLimitControl = '0',usedParcode = '1' ,productbycodeimage = '' ,commentClient='تعليق على العميل ',Inventoryevaluation='first',Profitevaluation='first' , delivery='-2',premiums = '0',operationnumEdit = '0',noOfDecimalPlaces = '2',unReviewBills = '0', unReviewBillsPass = '123',billReviewNote = '',tamweenBakery = '0',three_months = '0',six_months = '0',twelve_months = '0',eighteen_months = '0',twentyfour_months = '0',thirty_months = '0',sixthirty_months = '0',fortytwo_months = '0',fortyeight_months = '0',mandobCollectionRatio='0',takeAwayClient = '0',restaurantServiceOn = ',-2,-1,1,',earlyrepayment = '0',visaPay = '0',headerPrint='',headerPrintSand='',printSand='0',makeDailyEntry='0',clientShowTawla='0',billRest='1',suppIsClientToo='0',isCarBill='0',expensesproduct='1',projectshownew='1',showparcode='1',changeBuyPriceChangeSellInBuyBillCtrl = '0',changeBuyPriceChangeSellInProductCtrl = '0',inventoryvaluation = '1',showBillCollectionSearch='1',incomeclient='1',showserial='1',editservice='1',showCurrency='0',qrerp='1',valueadded='0',qrcodesh='1',printfoot='',sellorder='1',numberprint='0',valueaddedbuy='0',simpleAddClientInBill='0',licenseNo='',maintenance='0',showPrevDiscount='0',vatvalueqr='0.13043479',imgprinthide='0',parcodeprinttype = 'C128A',parcodeprintwidth='160',parcodeprinttextsize='14',parcodeprintCurr='L.E',sizecolorDigits='3',searchBarcodeInBill='0',allowMobileLogin='0',lanAllowType='0',wanAllowType='0',sendBillToRestaurant='0',obgyPharmacyGroups='',updateProUnitPricesOnPriceUpdate='0',ebill='0',valueaddeddiscount='0',clientdetail='1',showPrevPricesRet='0',showPrevDiscountRet='0',eunitInTax='',showStoreToDetail='0',showBuyPriceAtProductddl='0',specialexpenses='1',ratioshow='0',defaultUnitPriceAtBill='0',rulers='1',quantitynew='0',showBillOperationSearch='0',obygyFolder='',clientsell='0',
                preorderperiod='0',useListPrice='0',ebillclient='0',importproduct='1',realestateunits='0',expensesupplier='0',changeOrderproduct='0',searchlimit='0',typebill='',roundnumbersbilltotal='0',noOfDecimalPlacesBillTotal='2',dailyEntryCostprice='first',storeRecieveType='0',clientPhoneReq='0',addServiceToBill='0',realestatedev='1',showprice4='0',showprice5='0',showprice6='0',showprice7='0',showprice8='0',showpriceall='1',showpricehalf='1',showpriceunit='1',showbillstatus='0',showbilldeliverydate='0',enablequantityfractions='0',addclienttoproduct='0',closingcustomeraccount='0',serial2='9c2d4cf4cf5d4e24d5070164705832c3a5d1287f641a2960e48e04ae57a2ad0a5441322ca7cf34efd63003fdb348adbd0b61197c7c87d8dd5bc298c352482bc6',
                shownameE='0',showprocode='0',showpartnumber='0',showtype='0',showcompany='0',showweight='0',showorigin='0',showhscode='0',showexpire='0',showgrantduration='0',showonline='0',showminappear='0',showonlinecat='0',showsellpercentage='0',showbuydiscount='0',preparingStore='1',sellordername='0',showsearchfilter='0',unitPriceAtsalesreport='0',medExCat='0',laterNakdiClientId='0',headerPrint12Right='',headerPrint12Left='',halfPriceStart='0',allPriceStart='0',checkretsellclient='2' WHERE programsettingsid = '1';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:27:14";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 10:57:14", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 10:57:14', '75', '', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE programsettings SET companyname = 'BRAVO STORE', address = '8 شارع بورسعيد امام مستشفى السيد جلال', specializtion = 'Shoes ', phone = '01000464376', faxnumber = '0502232923', email = 'mrabozied@gt4it.com', website = 'www.gt4host.com', logo = '7e5a967475936eb131e45001c916f002.jpg', roundnumbers = '0', saveprinting = '0', deptprinting = '0', printingpapersize = '0', userid = '1', showPreviousPrice = '0', parcode = '0', priceing = '0', lastprice = '0', searchvalue = '1',clientsearchvalue = '3', updateproductprice = '0', allowfinsldelete = '0', updateclientprice = '0', `partition` = '0', taxcard = '332', commercialregistration = '3213123312', costcenter = '1', clinic = '1', workshop = '1', transport = '1', manufacturing = '0', masterCopy = '0' , dailyentrydate = '2020-04-18' ,updatefiledate = '2024-12-20',workerbetweenstores = '1',workshoptimeout = '24',drivertimeout = '3',currancy = 'جنيه',serial='7d1e8143a130fbea73dd3b9428a2caad8616ba42c98c2ee7a1bee8768760601b26945ac68358157bd4fc715be3f2049d90617f7a25078b4fb12d780f17ff8d26',allowdateedit = '1', clientcode = '1' ,clientserial = '1',timezone = 'Africa/Cairo' , expiredate ='1' , production ='1' , description='1' , service ='1' , date='1' , limitamount = '1' , measuringunit = '1' , print_amount = '0' , billid = '0' , precentages = '1' , realprice = '1' ,delegate_seller = '0' , storeserial = '1' ,clientfieldrequired ='0' , clientcodname='0' , colortype = '0' , nakdyOnly = '0' , nakdyKashf = '0' , discount_pres_direct = '0' , general_discount = '0' , sells_return = '0' ,scunitname ='0',vatValue = '0.00',syncstructure = '1',showPrevPrices = '0',isOpticProg='1',reportsPlusHours = '2' , showM5zon = '1',restaurantStoreId = '1',restuarantPrintTimeout = '8',sumSameProductForStore = '0', editAllPrice = '1', isCafe = '0' ,isRestaurent = '0' ,productDays = '0',thereIsRestTax = '0',restTaxVal = '0',restPrintLang = '0',taxNameFlag = '0',parcodeDigits = '5' ,specializedParcodeDigits = '7', clientDefaultDebtLimit = '10000' , clientDefaultDebtLimitControl = '0',usedParcode = '1' ,productbycodeimage = '' ,commentClient='تعليق على العميل ',Inventoryevaluation='first',Profitevaluation='first' , delivery='-2',premiums = '0',operationnumEdit = '0',noOfDecimalPlaces = '2',unReviewBills = '0', unReviewBillsPass = '123',billReviewNote = '',tamweenBakery = '0',three_months = '0',six_months = '0',twelve_months = '0',eighteen_months = '0',twentyfour_months = '0',thirty_months = '0',sixthirty_months = '0',fortytwo_months = '0',fortyeight_months = '0',mandobCollectionRatio='0',takeAwayClient = '0',restaurantServiceOn = ',-2,-1,1,',earlyrepayment = '0',visaPay = '0',headerPrint='',headerPrintSand='',printSand='0',makeDailyEntry='0',clientShowTawla='0',billRest='1',suppIsClientToo='0',isCarBill='0',expensesproduct='1',projectshownew='1',showparcode='1',changeBuyPriceChangeSellInBuyBillCtrl = '0',changeBuyPriceChangeSellInProductCtrl = '0',inventoryvaluation = '1',showBillCollectionSearch='1',incomeclient='1',showserial='1',editservice='1',showCurrency='0',qrerp='1',valueadded='0',qrcodesh='1',printfoot='',sellorder='1',numberprint='0',valueaddedbuy='0',simpleAddClientInBill='0',licenseNo='',maintenance='0',showPrevDiscount='0',vatvalueqr='0.13043479',imgprinthide='0',parcodeprinttype = 'C128A',parcodeprintwidth='160',parcodeprinttextsize='14',parcodeprintCurr='L.E',sizecolorDigits='3',searchBarcodeInBill='0',allowMobileLogin='0',lanAllowType='0',wanAllowType='0',sendBillToRestaurant='0',obgyPharmacyGroups='',updateProUnitPricesOnPriceUpdate='0',ebill='0',valueaddeddiscount='0',clientdetail='1',showPrevPricesRet='0',showPrevDiscountRet='0',eunitInTax='',showStoreToDetail='0',showBuyPriceAtProductddl='0',specialexpenses='1',ratioshow='0',defaultUnitPriceAtBill='0',rulers='1',quantitynew='0',showBillOperationSearch='0',obygyFolder='',clientsell='0',
                preorderperiod='0',useListPrice='0',ebillclient='0',importproduct='1',realestateunits='0',expensesupplier='0',changeOrderproduct='0',searchlimit='0',typebill='',roundnumbersbilltotal='0',noOfDecimalPlacesBillTotal='2',dailyEntryCostprice='first',storeRecieveType='0',clientPhoneReq='0',addServiceToBill='0',realestatedev='1',showprice4='0',showprice5='0',showprice6='0',showprice7='0',showprice8='0',showpriceall='1',showpricehalf='1',showpriceunit='1',showbillstatus='0',showbilldeliverydate='0',enablequantityfractions='0',addclienttoproduct='0',closingcustomeraccount='0',serial2='9c2d4cf4cf5d4e24d5070164705832c3a5d1287f641a2960e48e04ae57a2ad0a5441322ca7cf34efd63003fdb348adbd0b61197c7c87d8dd5bc298c352482bc6',
                shownameE='0',showprocode='0',showpartnumber='0',showtype='0',showcompany='0',showweight='0',showorigin='0',showhscode='0',showexpire='0',showgrantduration='0',showonline='0',showminappear='0',showonlinecat='0',showsellpercentage='0',showbuydiscount='0',preparingStore='1',sellordername='0',showsearchfilter='0',unitPriceAtsalesreport='0',medExCat='0',laterNakdiClientId='0',headerPrint12Right='',headerPrint12Left='',halfPriceStart='0',allPriceStart='0',checkretsellclient='2' WHERE programsettingsid = '1';
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:27:17";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:27:19";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 10:57:19", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 10:57:19', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:27:22";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 10:57:22", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 10:57:22', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('اية مدينة نصر 58' , '', '', '01015779764', '0', '', '0', '2024-12-20 10:58:43', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10762', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10762','0','0','0','إضافة عميل جديد','10762', '0', '2024-12-20 10:58:43', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('اية مدينة نصر 58', 'اية مدينة نصر 58', 'اية مدينة نصر 58', 'اية مدينة نصر 58', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-20 10:58:43');
UPDATE client SET clientname = 'اية مدينة نصر 58', clientaddress = '', clientphone = '', clientmobile = '01015779764', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '75'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12599',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10762';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:29:28";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 10:59:28", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 10:59:28', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765316fc7e06
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10762,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 10:57:19', '06765316fc7e06', '10762', '0.00', '303', '0', '1', '303.00', '303', '0', '303', '1', '2024-12-20 10:59:28', '', '75', '0', 'اية مدينة نصر 58', '2', '1', '3', '80', 'اية مدينة نصر 58', '2' ,'0','','','','','-1','0','0','0','0','0','303','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '303', userid = '75' WHERE clientid = '10762';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10762','0.00','303','0','اضافة فاتورة مبيعات','150322', '303', '2024-12-20 10:59:28', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '303', '0', null, '0', null, null,'', '0','1','1','303','1','2024-12-20 10:57:19','0','0');
UPDATE client SET  inUse = 0 where clientid = 10762;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35839;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','07185', '150322', '5', '16250', '1', '300', '300', '0', '', '1', '2024-12-20 10:59:28', '16250', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35839-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549184;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16250, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '75', storedetaildate = '2024-12-20 10:59:28' WHERE storedetailid = '16249';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16250', '1', '1', '1', '150322', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-20 10:59:28','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150322', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-20 10:59:28', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','3','3','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 80 where clientid = 10762;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 303, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+303, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10762, '2024-12-20', 303, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+303, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 303, 240, 240
                    , 240, 240, 240, 240, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+303, netSellCostBuyPrice = netSellCostBuyPrice+240
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+240
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+240
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+240
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+240
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+240
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+240
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+240;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765316fc7e06 and sellbillId = 150322 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:29:29";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 10:59:29", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 10:59:29', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:34:42";
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:35:14";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 11:05:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 11:05:14', '104', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:35:15";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:35:18";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 11:05:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:05:18', '104', 'addsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:37:49";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 11:07:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:07:49', '104', 'addAndRetuen', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765334e690be
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:05:18', '06765334e690be', '1', '0.00', '0', '0', '1', '750.00', '750', '750', '0', '1', '2024-12-20 11:07:49', '', '104', '0', 'نقدي', '1', '0', '3', '26', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','750','0','','0','0','750','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150323', '0', '2024-12-20 11:07:49', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '750', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:05:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35965;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','07218', '150323', '5', '16316', '1', '300', '300', '0', '', '1', '2024-12-20 11:07:49', '16316', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35965-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 225.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 225.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 225, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549186;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16316, '2024-12-20', 300, 225, 225
                    , 225, 225, 225, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 225, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+225
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+225
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+225
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 225, 225
                    , 225, 225, 225, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 225, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+225
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+225
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+225
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '16', userid = '104', storedetaildate = '2024-12-20 11:07:49' WHERE storedetailid = '16315';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16316', '1', '1', '1', '150323', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '104', '2024-12-20 11:07:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35805;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('375','07072', '150323', '5', '16053', '1', '450', '450', '0', '', '1', '2024-12-20 11:07:49', '16053', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35805-1,','1','1','0','0','450','450','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 375.00 , meanbuyprice = 375.00, lastbuyprice_withDiscount = 375.00, meanbuyprice_withDiscount = 375.00
        , lastbuyprice_withTax = 375, meanbuyprice_withTax = 375, lastbuyprice_withDiscountAndTax = 375
                where sellbilldetailid = 549187;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16053, '2024-12-20', 450, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+375
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+375
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+375
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 450, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+375
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+375
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+375
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '104', storedetaildate = '2024-12-20 11:07:49' WHERE storedetailid = '16052';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16053', '1', '1', '1', '150323', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-20 11:07:49','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '750',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('0','750', '0', '1', 'اضافة فاتورة مبيعات', '150323', '750', '2024-12-20 11:07:49', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 26 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 750, 600, 600
                    , 600, 600, 600, 600
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,600, 600, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+600
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+600
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 750, 600, 600
                    , 600, 600, 600, 600
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,600, 600, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+600
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+600
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 750, 600, 600
                    , 600, 600, 600, 600, 600, 600)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+750, netSellCostBuyPrice = netSellCostBuyPrice+600
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+600
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+600
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+600
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+600
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+600
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+600
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+600;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765334e690be and sellbillId = 150323 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:37:49";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 11:07:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:07:50', '104', 'addsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE userid = 104;
UPDATE user SET loginip = "" WHERE userid = 101;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:43:18";
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:43:40";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:13:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 11:13:40', '104', '', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:43:41";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:43:59";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:13:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:13:59', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:44:10";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:14:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:14:10', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:45:06";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:15:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:15:06', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765356329279
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 11:14:11', '06765356329279', '1', '0.00', '0', '0', '1', '310', '310', '-310', '0', '1', '2024-12-20 11:15:06', '', '104', '0', 'نقدي','1', '0', '5', '92', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-310','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16844', '0', '2024-12-20 11:15:06', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '310', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:14:11','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('250.00', '07205', '16844', '5', '16302', '1', '310', '310', '0', '', '1', '0', '16302', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','310','310','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where returnsellbilldetailid = 22033;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16302, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 310, 250, 250, 250
                    , 250, 250, 250, 0, 1, 0, 0, 250, 250)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+310, returnSellCostBuyPrice = returnSellCostBuyPrice+250, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+250
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+250, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+250
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+250
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+250
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+250
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+250
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 310, 250, 250, 250
                    , 250, 250, 250, 0, 0, 250, 250)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+310, returnSellCostBuyPrice = returnSellCostBuyPrice+250, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+250
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+250, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+250
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+250
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+250
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+250
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+250;
UPDATE storedetail SET  productquantity = '9', userid = '104', storedetaildate = '2024-12-20 11:15:06' WHERE storedetailid = '16301';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16302', '1', '1', '0', '16844', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '8', '9', '104', '2024-12-20 11:15:06','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '440',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('750','-310', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16844', '440', '2024-12-20 11:15:06', '104',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 92 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 310, 250, 250, 250
                    , 250, 250, 250 ,0, 0, 250, 250)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+310, returnSellCostBuyPrice = returnSellCostBuyPrice+250, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+250
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+250, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+250
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+250
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+250
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+250
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+250;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 310, 250, 250, 250
                    , 250, 250, 250 ,0, 0, 250, 250)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+310, returnSellCostBuyPrice = returnSellCostBuyPrice+250, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+250
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+250, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+250
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+250
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+250
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+250
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+250;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -310, -250, -250
                    , -250, -250, -250, -250, -250, -250)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-310, netSellCostBuyPrice = netSellCostBuyPrice+-250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-250
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-250
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-250
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-250
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-250;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765356329279 and sellbillId = 16844 and returnsellbillId = 16844
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:45:06";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:15:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:15:06', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:48:48";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:18:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:18:48', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067653557f22e8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:13:59', '067653557f22e8', '1', '0.00', '0', '0', '1', '1030.00', '1030', '1030', '0', '1', '2024-12-20 11:18:48', '', '104', '0', 'نقدي', '1', '0', '3', '83', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1030','0','','0','0','1030','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150324', '0', '2024-12-20 11:18:48', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1030', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:13:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35659;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('180','H1520', '150324', '14', '16016', '1', '300', '300', '0', '', '1', '2024-12-20 11:18:48', '16016', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35659-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 168.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 168.00
        , lastbuyprice_withTax = 180, meanbuyprice_withTax = 157, lastbuyprice_withDiscountAndTax = 180
                where sellbilldetailid = 549188;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16016, '2024-12-20', 300, 180, 180
                    , 168, 180, 168, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 180, 157, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+168
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+168
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+157
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 180, 180
                    , 168, 180, 168, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 157, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+168
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+168
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+157
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '16', userid = '104', storedetaildate = '2024-12-20 11:18:48' WHERE storedetailid = '16015';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16016', '1', '1', '1', '150324', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '104', '2024-12-20 11:18:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36383;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('375','H1671', '150324', '14', '16447', '1', '480', '480', '0', '', '1', '2024-12-20 11:18:48', '16447', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36383-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 375.00 , meanbuyprice = 375.00, lastbuyprice_withDiscount = 375.00, meanbuyprice_withDiscount = 375.00
        , lastbuyprice_withTax = 375, meanbuyprice_withTax = 375, lastbuyprice_withDiscountAndTax = 375
                where sellbilldetailid = 549189;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16447, '2024-12-20', 480, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+375
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+375
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+375
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 480, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+375
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+375
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+375
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '17', userid = '104', storedetaildate = '2024-12-20 11:18:48' WHERE storedetailid = '16446';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16447', '1', '1', '1', '150324', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '104', '2024-12-20 11:18:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33478;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','R3111', '150324', '1', '15027', '1', '250', '250', '0', '', '1', '2024-12-20 11:18:48', '15027', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33478-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        
                where sellbilldetailid = 549190;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15027, '2024-12-20', 250, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 250, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-20 11:18:48' WHERE storedetailid = '15026';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15027', '1', '1', '1', '150324', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-20 11:18:48','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '1470',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('440','1030', '0', '1', 'اضافة فاتورة مبيعات', '150324', '1470', '2024-12-20 11:18:48', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 83 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1030, 755, 755
                    , 743, 755, 743, 755
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,555, 532, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1030, sellCostBuyPrice =sellCostBuyPrice+755
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+755, sellCostMeanBuyPrice = sellCostMeanBuyPrice+743
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+755, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+743
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+755
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+555
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+532
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1030, 755, 755
                    , 743, 755, 743, 755
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,555, 532, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1030, sellCostBuyPrice =sellCostBuyPrice+755
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+755, sellCostMeanBuyPrice = sellCostMeanBuyPrice+743
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+755, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+743
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+755
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+555
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+532
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1030, 755, 755
                    , 743, 755, 743, 755, 555, 532)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1030, netSellCostBuyPrice = netSellCostBuyPrice+755
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+755
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+743
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+755
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+743
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+755
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+555
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+532;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067653557f22e8 and sellbillId = 150324 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:48:49";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:18:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:18:49', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:50:49";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:20:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:20:49', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765367952188
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:18:49', '06765367952188', '1', '0.00', '0', '0', '1', '400.00', '400', '400', '0', '1', '2024-12-20 11:20:49', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','400','0','','0','0','400','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150325', '0', '2024-12-20 11:20:49', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:18:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36121;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','10445', '150325', '5', '16347', '1', '200', '200', '0', '', '1', '2024-12-20 11:20:49', '16347', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36121-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 137.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 137.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 134, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549191;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16347, '2024-12-20', 200, 140, 140
                    , 137, 140, 137, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 134, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+137
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+137
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+134
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 137, 140, 137, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 134, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+137
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+137
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+134
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '104', storedetaildate = '2024-12-20 11:20:49' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '1', '1', '150325', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-20 11:20:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36314;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07228', '150325', '5', '16348', '1', '200', '200', '0', '', '1', '2024-12-20 11:20:49', '16348', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36314-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 139.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 139.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 139, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549192;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16348, '2024-12-20', 200, 140, 140
                    , 139, 140, 139, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 139, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+139
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+139
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+139
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 139, 140, 139, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 139, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+139
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+139
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+139
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '27', userid = '104', storedetaildate = '2024-12-20 11:20:49' WHERE storedetailid = '16347';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16348', '1', '1', '1', '150325', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '27', '104', '2024-12-20 11:20:49','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '1870',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('1470','400', '0', '1', 'اضافة فاتورة مبيعات', '150325', '1870', '2024-12-20 11:20:49', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 400, 280, 280
                    , 276, 280, 276, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 273, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+276
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+276
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+273
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 280, 280
                    , 276, 280, 276, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 273, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+276
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+276
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+273
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 400, 280, 280
                    , 276, 280, 276, 280, 280, 273)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+400, netSellCostBuyPrice = netSellCostBuyPrice+280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+276
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+276
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+280
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+280
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+273;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765367952188 and sellbillId = 150325 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:50:50";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:20:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:20:50', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:52:05";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:22:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:22:05', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676536f26d8bf
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:20:50', '0676536f26d8bf', '1', '0.00', '0', '0', '1', '920.00', '920', '920', '0', '1', '2024-12-20 11:22:05', '', '104', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','920','0','','0','0','920','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150326', '0', '2024-12-20 11:22:05', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '920', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:20:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35046;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('575','H1369', '150326', '14', '15545', '1', '650', '650', '0', '', '1', '2024-12-20 11:22:05', '15545', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35046-1,','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 575.00 , meanbuyprice = 575.00, lastbuyprice_withDiscount = 575.00, meanbuyprice_withDiscount = 575.00
        , lastbuyprice_withTax = 575, meanbuyprice_withTax = 392, lastbuyprice_withDiscountAndTax = 575
                where sellbilldetailid = 549193;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15545, '2024-12-20', 650, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 575, 392, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+392
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 650, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0, 575, 392, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+392
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-20 11:22:05' WHERE storedetailid = '15544';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15545', '1', '1', '1', '150326', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-20 11:22:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35848;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','H1613', '150326', '14', '16257', '1', '270', '270', '0', '', '1', '2024-12-20 11:22:05', '16257', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35848-1,','1','1','0','0','270','270','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 549194;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16257, '2024-12-20', 270, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 270, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '104', storedetaildate = '2024-12-20 11:22:05' WHERE storedetailid = '16256';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16257', '1', '1', '1', '150326', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-20 11:22:05','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2790',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('1870','920', '0', '1', 'اضافة فاتورة مبيعات', '150326', '2790', '2024-12-20 11:22:05', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 24 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 920, 775, 775
                    , 775, 775, 775, 775
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,775, 592, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+920, sellCostBuyPrice =sellCostBuyPrice+775
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+775, sellCostMeanBuyPrice = sellCostMeanBuyPrice+775
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+775, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+775
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+775
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+775
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+592
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 920, 775, 775
                    , 775, 775, 775, 775
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,775, 592, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+920, sellCostBuyPrice =sellCostBuyPrice+775
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+775, sellCostMeanBuyPrice = sellCostMeanBuyPrice+775
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+775, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+775
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+775
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+775
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+592
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 920, 775, 775
                    , 775, 775, 775, 775, 775, 592)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+920, netSellCostBuyPrice = netSellCostBuyPrice+775
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+775
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+775
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+775
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+775
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+775
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+775
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+592;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676536f26d8bf and sellbillId = 150326 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:52:06";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:22:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:22:06', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:52:50";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:22:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:22:50', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765373eb2ff3
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:22:06', '06765373eb2ff3', '1', '0.00', '0', '0', '1', '430.00', '430', '430', '0', '1', '2024-12-20 11:22:50', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','430','0','','0','0','430','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150327', '0', '2024-12-20 11:22:50', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '430', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:22:06','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('360','H1455', '150327', '14', '15838', '1', '430', '430', '0', '', '1', '2024-12-20 11:22:50', '15838', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','430','430','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 359.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 359.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 359, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549195;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15838, '2024-12-20', 430, 360, 360
                    , 359, 360, 359, 356.92
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 359, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+359
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+359
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+356.92
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+359
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 430, 360, 360
                    , 359, 360, 359, 356.92
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 359, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+359
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+359
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+356.92
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+359
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '104', storedetaildate = '2024-12-20 11:22:51' WHERE storedetailid = '15837';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15838', '1', '1', '1', '150327', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-20 11:22:51','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '3220',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2790','430', '0', '1', 'اضافة فاتورة مبيعات', '150327', '3220', '2024-12-20 11:22:51', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 430, 360, 360
                    , 359, 360, 359, 356.92
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 359, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+359
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+359
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+356.92
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+359
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 430, 360, 360
                    , 359, 360, 359, 356.92
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 359, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+359
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+359
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+356.92
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+359
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 430, 360, 360
                    , 359, 360, 359, 356.92, 360, 359)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+430, netSellCostBuyPrice = netSellCostBuyPrice+360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+359
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+359
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+356.92
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+360
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+359;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765373eb2ff3 and sellbillId = 150327 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:52:51";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:22:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:22:51', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:53:20";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:23:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:23:20', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765376bcf7e2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:22:51', '06765376bcf7e2', '1', '0.00', '0', '0', '1', '320.00', '320', '320', '0', '1', '2024-12-20 11:23:20', '', '104', '0', 'نقدي', '1', '0', '3', '25', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','320','0','','0','0','320','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150328', '0', '2024-12-20 11:23:20', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '320', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:22:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35928;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('280','07198', '150328', '5', '16304', '1', '320', '320', '0', '', '1', '2024-12-20 11:23:20', '16304', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35928-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 280, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 549196;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16304, '2024-12-20', 320, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '104', storedetaildate = '2024-12-20 11:23:20' WHERE storedetailid = '16303';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16304', '1', '1', '1', '150328', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-20 11:23:20','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '3540',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('3220','320', '0', '1', 'اضافة فاتورة مبيعات', '150328', '3540', '2024-12-20 11:23:20', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 25 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 320, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 320, 280, 280
                    , 280, 280, 280, 280, 280, 280)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+320, netSellCostBuyPrice = netSellCostBuyPrice+280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+280
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+280
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+280
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+280
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+280;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765376bcf7e2 and sellbillId = 150328 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:53:21";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:23:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:23:21', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:54:03";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:24:03", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:24:03', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067653789b3c9d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:23:21', '067653789b3c9d', '1', '0.00', '0', '0', '1', '140.00', '140', '140', '0', '1', '2024-12-20 11:24:03', '', '104', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','140','0','','0','0','140','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150329', '0', '2024-12-20 11:24:03', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '140', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:23:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33803;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('165','06719', '150329', '5', '15243', '1', '140', '140', '0', '', '1', '2024-12-20 11:24:03', '15243', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33803-1,','1','1','0','0','140','140','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 198.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 198.00
        
                where sellbilldetailid = 549197;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15243, '2024-12-20', 140, 165, 165
                    , 198, 165, 198, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+140, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+198
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+198
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 140, 165, 165
                    , 198, 165, 198, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+140, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+198
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+198
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-20 11:24:03' WHERE storedetailid = '15242';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15243', '1', '1', '1', '150329', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-20 11:24:03','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '3680',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('3540','140', '0', '1', 'اضافة فاتورة مبيعات', '150329', '3680', '2024-12-20 11:24:03', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 24 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 140, 165, 165
                    , 198, 165, 198, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+140, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+198
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+198
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 140, 165, 165
                    , 198, 165, 198, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+140, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+198
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+198
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 140, 165, 165
                    , 198, 165, 198, 165, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+140, netSellCostBuyPrice = netSellCostBuyPrice+165
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+165
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+198
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+165
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+198
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+165
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067653789b3c9d and sellbillId = 150329 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:54:04";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:24:04", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:24:04', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:54:35";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:24:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:24:35', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676537b4aa58a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:24:04', '0676537b4aa58a', '1', '0.00', '0', '0', '1', '210.00', '210', '210', '0', '1', '2024-12-20 11:24:35', '', '104', '0', 'نقدي', '1', '0', '3', '54', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','210','0','','0','0','210','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150330', '0', '2024-12-20 11:24:35', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '210', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:24:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36142;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07226', '150330', '5', '16294', '1', '210', '210', '0', '', '1', '2024-12-20 11:24:35', '16294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36142-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 151.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 151.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 153, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549198;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16294, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '75', userid = '104', storedetaildate = '2024-12-20 11:24:35' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '1', '150330', 'اضافة فاتورة مبيعات', 'sellbillController.php', '76', '75', '104', '2024-12-20 11:24:35','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '3890',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('3680','210', '0', '1', 'اضافة فاتورة مبيعات', '150330', '3890', '2024-12-20 11:24:36', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 54 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 210, 155, 155
                    , 151, 155, 151, 153.12, 155, 153)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+210, netSellCostBuyPrice = netSellCostBuyPrice+155
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+155
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+151
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+155
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+151
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+153.12
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+155
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+153;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676537b4aa58a and sellbillId = 150330 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:54:36";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:24:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:24:36', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:56:26";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:26:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:26:26', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676537d4ae285
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:24:36', '0676537d4ae285', '1', '0.00', '0', '0', '1', '360.00', '360', '360', '0', '1', '2024-12-20 11:26:27', '', '104', '0', 'نقدي', '1', '0', '3', '25', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','360','0','','0','0','360','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150331', '0', '2024-12-20 11:26:27', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '360', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:24:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35790;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','78808', '150331', '5', '15674', '1', '360', '360', '0', '', '1', '2024-12-20 11:26:27', '15674', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35790-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 295.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 295.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295
                where sellbilldetailid = 549199;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15674, '2024-12-20', 360, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '31', userid = '104', storedetaildate = '2024-12-20 11:26:27' WHERE storedetailid = '15673';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15674', '1', '1', '1', '150331', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32', '31', '104', '2024-12-20 11:26:27','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '4250',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('3890','360', '0', '1', 'اضافة فاتورة مبيعات', '150331', '4250', '2024-12-20 11:26:27', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 25 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 360, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 360, 295, 295
                    , 295, 295, 295, 295, 295, 295)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+360, netSellCostBuyPrice = netSellCostBuyPrice+295
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+295
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+295
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+295
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+295
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+295
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+295
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+295;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676537d4ae285 and sellbillId = 150331 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:56:27";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:26:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:26:27', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:57:46";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:27:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:27:46', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067653843e21c6
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:26:27', '067653843e21c6', '1', '0.00', '0', '0', '1', '900.00', '900', '900', '0', '1', '2024-12-20 11:27:46', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','900','0','','0','0','900','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150332', '0', '2024-12-20 11:27:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '900', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:26:27','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('380','06107', '150332', '5', '13802', '1', '320', '320', '0', '', '1', '2024-12-20 11:27:46', '13802', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 532.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 532.00
        
                where sellbilldetailid = 549200;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13802, '2024-12-20', 320, 380, 380
                    , 532, 380, 532, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+532
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+532
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 380, 380
                    , 532, 380, 532, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+532
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+532
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '104', storedetaildate = '2024-12-20 11:27:46' WHERE storedetailid = '13801';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13802', '1', '1', '1', '150332', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '104', '2024-12-20 11:27:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18297;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('340','03965', '150332', '5', '8609', '1', '170', '170', '0', '', '1', '2024-12-20 11:27:46', '8609', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','18297-1,','1','1','0','0','170','170','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 340.00 , meanbuyprice = 363.00, lastbuyprice_withDiscount = 340.00, meanbuyprice_withDiscount = 363.00
        
                where sellbilldetailid = 549201;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8609, '2024-12-20', 170, 340, 340
                    , 363, 340, 363, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+363
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+363
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 170, 340, 340
                    , 363, 340, 363, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+363
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+363
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-20 11:27:46' WHERE storedetailid = '8608';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('8609', '1', '1', '1', '150332', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-20 11:27:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35630;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','07108', '150332', '5', '16174', '1', '410', '410', '0', '', '1', '2024-12-20 11:27:46', '16174', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35630-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 350, lastbuyprice_withDiscountAndTax = 350
                where sellbilldetailid = 549202;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16174, '2024-12-20', 410, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 410, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '104', storedetaildate = '2024-12-20 11:27:46' WHERE storedetailid = '16173';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16174', '1', '1', '1', '150332', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-20 11:27:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '5150',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('4250','900', '0', '1', 'اضافة فاتورة مبيعات', '150332', '5150', '2024-12-20 11:27:46', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 900, 1070, 1070
                    , 1245, 1070, 1245, 1070
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+1070
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1070, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1070, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1070
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 900, 1070, 1070
                    , 1245, 1070, 1245, 1070
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+1070
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1070, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1070, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1070
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 900, 1070, 1070
                    , 1245, 1070, 1245, 1070, 350, 350)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+900, netSellCostBuyPrice = netSellCostBuyPrice+1070
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1070
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1245
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1070
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1245
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1070
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+350
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+350;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067653843e21c6 and sellbillId = 150332 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:57:47";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:27:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:27:47', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:58:02";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:28:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 11:28:02', '104', '', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 07:58:18";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:28:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 11:28:18', '104', 'show', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:02:57";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:32:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:32:57', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:06:19";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:36:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:36:19', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676539c9b229b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:32:57', '0676539c9b229b', '1', '0.00', '0', '0', '1', '870.00', '870', '870', '0', '1', '2024-12-20 11:36:19', '', '104', '0', 'نقدي', '1', '0', '3', '54', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','870','0','','0','0','870','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150333', '0', '2024-12-20 11:36:19', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '870', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:32:57','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35978;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('790','H1627', '150333', '14', '16323', '1', '870', '870', '0', '', '1', '2024-12-20 11:36:19', '16323', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35978-1,','1','1','0','0','870','870','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 790.00 , meanbuyprice = 790.00, lastbuyprice_withDiscount = 790.00, meanbuyprice_withDiscount = 790.00
        , lastbuyprice_withTax = 790, meanbuyprice_withTax = 790, lastbuyprice_withDiscountAndTax = 790
                where sellbilldetailid = 549203;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16323, '2024-12-20', 870, 790, 790
                    , 790, 790, 790, 790
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 790, 790, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+870, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+790
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+790
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+790
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+790
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+790
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 870, 790, 790
                    , 790, 790, 790, 790
                    , 0, 0, 0, 0
                    , 0, 0, 0, 790, 790, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+870, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+790
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+790
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+790
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+790
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+790
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '104', storedetaildate = '2024-12-20 11:36:19' WHERE storedetailid = '16322';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16323', '1', '1', '1', '150333', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-20 11:36:19','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6020',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('5150','870', '0', '1', 'اضافة فاتورة مبيعات', '150333', '6020', '2024-12-20 11:36:19', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 54 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 870, 790, 790
                    , 790, 790, 790, 790
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,790, 790, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+870, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+790
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+790
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+790
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+790
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+790
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 870, 790, 790
                    , 790, 790, 790, 790
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,790, 790, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+870, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+790
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+790
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+790
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+790
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+790
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 870, 790, 790
                    , 790, 790, 790, 790, 790, 790)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+870, netSellCostBuyPrice = netSellCostBuyPrice+790
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+790
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+790
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+790
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+790
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+790
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+790
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+790;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676539c9b229b and sellbillId = 150333 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:06:20";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:36:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:36:20', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:07:26";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:37:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:37:26', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067653a9481b58
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:36:20', '067653a9481b58', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-20 11:37:26', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','300','0','','0','0','300','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150334', '0', '2024-12-20 11:37:26', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:36:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36248;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','07212', '150334', '5', '16355', '1', '300', '300', '0', '', '1', '2024-12-20 11:37:26', '16355', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36248-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 245.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 245.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 549204;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16355, '2024-12-20', 300, 250, 250
                    , 245, 250, 245, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 250, 250
                    , 245, 250, 245, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '104', storedetaildate = '2024-12-20 11:37:26' WHERE storedetailid = '16354';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16355', '1', '1', '1', '150334', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-20 11:37:26','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6320',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6020','300', '0', '1', 'اضافة فاتورة مبيعات', '150334', '6320', '2024-12-20 11:37:26', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 3 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 300, 250, 250
                    , 245, 250, 245, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,250, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 250, 250
                    , 245, 250, 245, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,250, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 300, 250, 250
                    , 245, 250, 245, 250, 250, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+245
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+245
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+250
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+250
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+240;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067653a9481b58 and sellbillId = 150334 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:07:27";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:37:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:37:27', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:09:21";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:39:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:39:21', '104', 'addAndRetuen', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067653ad7689ee
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:37:27', '067653ad7689ee', '1', '0.00', '0', '0', '1', '330.00', '330', '330', '0', '1', '2024-12-20 11:39:21', '', '104', '0', 'نقدي', '1', '0', '3', '96', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','330','0','','0','0','330','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150335', '0', '2024-12-20 11:39:21', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '330', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:37:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36390;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('265','07303', '150335', '5', '16452', '1', '330', '330', '0', '', '1', '2024-12-20 11:39:21', '16452', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36390-1,','1','1','0','0','330','330','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 265, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 549205;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16452, '2024-12-20', 330, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 330, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '22', userid = '104', storedetaildate = '2024-12-20 11:39:21' WHERE storedetailid = '16451';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16452', '1', '1', '1', '150335', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '104', '2024-12-20 11:39:21','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6650',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6320','330', '0', '1', 'اضافة فاتورة مبيعات', '150335', '6650', '2024-12-20 11:39:21', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 96 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 330, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 330, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 330, 265, 265
                    , 265, 265, 265, 265, 265, 265)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+330, netSellCostBuyPrice = netSellCostBuyPrice+265
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+265
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+265
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+265
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+265
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+265
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+265
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+265;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067653ad7689ee and sellbillId = 150335 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:09:22";
UPDATE user SET loginip = "197.52.155.2", lastactivetime = "2024-12-20 11:39:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:39:22', '104', 'addsellBill', '197.52.155.2', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:14:25";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 11:44:25", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:44:25', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676531f12bcf1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1519,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 10:59:29', '0676531f12bcf1', '1519', '0.00', '2677', '0', '1', '2677.00', '2677', '0', '2677', '1', '2024-12-20 11:44:26', '', '75', '0', 'هبة حسن اسكندرية 58', '2', '1', '3', '80', 'هبة حسن اسكندرية 58', '10' ,'0','','','','','-1','0','0','0','0','0','2677','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2677', userid = '75' WHERE clientid = '1519';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1519','0.00','2677','0','اضافة فاتورة مبيعات','150336', '2677', '2024-12-20 11:44:26', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2677', '0', null, '0', null, null,'', '0','1','1','2677','1','2024-12-20 10:59:29','0','0');
UPDATE client SET  inUse = 0 where clientid = 1519;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36310;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('365','H1656', '150336', '14', '16413', '1', '440', '440', '0', '', '1', '2024-12-20 11:44:26', '16413', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36310-1,','1','1','0','0','440','440','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 365.00 , meanbuyprice = 365.00, lastbuyprice_withDiscount = 365.00, meanbuyprice_withDiscount = 365.00
        , lastbuyprice_withTax = 365, meanbuyprice_withTax = 365, lastbuyprice_withDiscountAndTax = 365
                where sellbilldetailid = 549206;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16413, '2024-12-20', 440, 365, 365
                    , 365, 365, 365, 365
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 365, 365, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+365
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+365, sellCostMeanBuyPrice = sellCostMeanBuyPrice+365
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+365, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+365
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+365
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+365
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+365
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 440, 365, 365
                    , 365, 365, 365, 365
                    , 0, 0, 0, 0
                    , 0, 0, 0, 365, 365, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+365
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+365, sellCostMeanBuyPrice = sellCostMeanBuyPrice+365
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+365, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+365
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+365
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+365
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+365
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '24', userid = '75', storedetaildate = '2024-12-20 11:44:26' WHERE storedetailid = '16412';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16413', '1', '1', '1', '150336', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '75', '2024-12-20 11:44:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35802;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('190','06951', '150336', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-20 11:44:26', '15850', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35802-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 188, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 549207;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15850, '2024-12-20', 240, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 190, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+188
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 240, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+188
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '42', userid = '75', storedetaildate = '2024-12-20 11:44:26' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '150336', 'اضافة فاتورة مبيعات', 'sellbillController.php', '43', '42', '75', '2024-12-20 11:44:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36358;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06603', '150336', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-20 11:44:26', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36358-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 226.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 226.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 227, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549208;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15038, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '53', userid = '75', storedetaildate = '2024-12-20 11:44:26' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '150336', 'اضافة فاتورة مبيعات', 'sellbillController.php', '54', '53', '75', '2024-12-20 11:44:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36184;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('455','07280', '150336', '5', '16390', '1', '550', '550', '0', '', '1', '2024-12-20 11:44:26', '16390', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36184-1,','1','1','0','0','550','550','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 455.00 , meanbuyprice = 455.00, lastbuyprice_withDiscount = 455.00, meanbuyprice_withDiscount = 455.00
        , lastbuyprice_withTax = 455, meanbuyprice_withTax = 455, lastbuyprice_withDiscountAndTax = 455
                where sellbilldetailid = 549209;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16390, '2024-12-20', 550, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+455
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+455, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+455, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+455
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+455
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+455
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 550, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+455
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+455, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+455, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+455
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+455
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+455
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '75', storedetaildate = '2024-12-20 11:44:26' WHERE storedetailid = '16389';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16390', '1', '1', '1', '150336', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-20 11:44:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36336;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','23664', '150336', '5', '15673', '1', '360', '360', '0', '', '1', '2024-12-20 11:44:26', '15673', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36336-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 295.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 295.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 549210;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15673, '2024-12-20', 360, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '32', userid = '75', storedetaildate = '2024-12-20 11:44:26' WHERE storedetailid = '15672';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15673', '1', '1', '1', '150336', 'اضافة فاتورة مبيعات', 'sellbillController.php', '33', '32', '75', '2024-12-20 11:44:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35993;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','07250', '150336', '5', '16338', '1', '300', '300', '0', '', '1', '2024-12-20 11:44:26', '16338', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35993-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549211;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16338, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '75', storedetaildate = '2024-12-20 11:44:26' WHERE storedetailid = '16337';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16338', '1', '1', '1', '150336', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-20 11:44:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36142;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07226', '150336', '5', '16294', '1', '210', '210', '0', '', '1', '2024-12-20 11:44:26', '16294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36142-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 151.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 151.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 153, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549212;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16294, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '74', userid = '75', storedetaildate = '2024-12-20 11:44:26' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '1', '150336', 'اضافة فاتورة مبيعات', 'sellbillController.php', '75', '74', '75', '2024-12-20 11:44:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36167;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','07131', '150336', '5', '16152', '1', '240', '240', '0', '', '1', '2024-12-20 11:44:26', '16152', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36167-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 549213;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16152, '2024-12-20', 240, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 240, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '24', userid = '75', storedetaildate = '2024-12-20 11:44:26' WHERE storedetailid = '16151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16152', '1', '1', '1', '150336', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '75', '2024-12-20 11:44:26','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150336', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 11:44:26', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150336', '17', '10291', '1', '27', '27', '0', '', '1', '2024-12-20 11:44:26', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','27','27','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 80 where clientid = 1519;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2677, 2125, 2125
                    , 2122, 2125, 2122, 2134.07
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2125, 2123, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2677, sellCostBuyPrice =sellCostBuyPrice+2125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2122
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2122
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2134.07
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2125
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2123
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1519, '2024-12-20', 2677, 2125, 2125
                    , 2122, 2125, 2122, 2134.07
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2125, 2123, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2677, sellCostBuyPrice =sellCostBuyPrice+2125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2122
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2122
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2134.07
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2125
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2123
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2677, 2125, 2125
                    , 2122, 2125, 2122, 2134.07, 2125, 2123)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2677, netSellCostBuyPrice = netSellCostBuyPrice+2125
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2125
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2122
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2125
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2122
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2134.07
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2125
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2123;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676531f12bcf1 and sellbillId = 150336 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:14:27";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 11:44:27", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:44:27', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:20:14";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 11:50:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:50:14', '104', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067653b4ab11a5
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:39:22', '067653b4ab11a5', '1', '0.00', '0', '0', '1', '360.00', '360', '360', '0', '1', '2024-12-20 11:50:14', '', '104', '0', 'نقدي', '1', '0', '3', '21', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','360','0','','0','0','360','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150337', '0', '2024-12-20 11:50:14', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '360', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 11:39:22','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35842;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','06872', '150337', '5', '15654', '1', '360', '360', '0', '', '1', '2024-12-20 11:50:14', '15654', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35842-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 356.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 356.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 356, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 549216;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15654, '2024-12-20', 360, 295, 295
                    , 356, 295, 356, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 356, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+356
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+356
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+356
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 295, 295
                    , 356, 295, 356, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 356, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+356
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+356
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+356
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '104', storedetaildate = '2024-12-20 11:50:14' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '1', '1', '150337', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-20 11:50:14','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7010',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6650','360', '0', '1', 'اضافة فاتورة مبيعات', '150337', '7010', '2024-12-20 11:50:14', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 21 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 360, 295, 295
                    , 356, 295, 356, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 356, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+356
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+356
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+356
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 295, 295
                    , 356, 295, 356, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 356, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+356
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+356
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+356
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 360, 295, 295
                    , 356, 295, 356, 295, 295, 356)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+360, netSellCostBuyPrice = netSellCostBuyPrice+295
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+295
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+356
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+295
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+356
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+295
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+295
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+356;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067653b4ab11a5 and sellbillId = 150337 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:20:21";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 11:50:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 11:50:21', '104', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('محل مول هيلز 25' , '', '', '01002811231', '0', '', '0', '2024-12-20 11:54:20', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10763', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10763','0','0','0','إضافة عميل جديد','10763', '0', '2024-12-20 11:54:20', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('محل مول هيلز 25', 'محل مول هيلز 25', 'محل مول هيلز 25', 'محل مول هيلز 25', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-20 11:54:20');
UPDATE client SET clientname = 'محل مول هيلز 25', clientaddress = '', clientphone = '', clientmobile = '01002811231', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '75'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12600',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10763';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:26:52";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 11:56:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 11:56:52', '104', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:27:46";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 11:57:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 11:57:46', '104', 'add', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'كروت شحن', '', '40', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '6970',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7010.00','40', '1', '1', 'إضافة مصروف', '25894', '6970', '2024-12-20 11:57:46', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كروت شحن', expensesdetails = '', expensesValue = '40.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25894';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:27:47";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 11:57:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 11:57:47', '104', 'sucess', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:27:49";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 11:57:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 11:57:49', '104', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:28:58";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 11:58:58", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 11:58:58', '104', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:30:44";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 12:00:44", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:00:44', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067653c7b432a8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10763,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 11:44:27', '067653c7b432a8', '10763', '0.00', '6591', '0', '1', '6591.00', '6591', '0', '6591', '1', '2024-12-20 12:00:44', '', '75', '0', 'محل مول هيلز 25', '2', '1', '3', '78', 'محل مول هيلز 25', '15' ,'0','','','','','-1','0','0','0','0','0','6591','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '6591', userid = '75' WHERE clientid = '10763';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10763','0.00','6591','0','اضافة فاتورة مبيعات','150338', '6591', '2024-12-20 12:00:44', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '6591', '0', null, '0', null, null,'', '0','1','1','6591','1','2024-12-20 11:44:27','0','0');
UPDATE client SET  inUse = 0 where clientid = 10763;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 35151;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('385','R3292', '150338', '1', '15921', '3', '450', '1350', '0', '', '1', '2024-12-20 12:00:44', '15921', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35151-3,','1','1','0','0','450','1350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 385.00 , meanbuyprice = 385.00, lastbuyprice_withDiscount = 385.00, meanbuyprice_withDiscount = 385.00
        , lastbuyprice_withTax = 385, meanbuyprice_withTax = 385, lastbuyprice_withDiscountAndTax = 385
                where sellbilldetailid = 549217;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15921, '2024-12-20', 1350, 1155, 1155
                    , 1155, 1155, 1155, 1155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 1155, 1155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1350, sellCostBuyPrice =sellCostBuyPrice+1155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1350, 1155, 1155
                    , 1155, 1155, 1155, 1155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1155, 1155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1350, sellCostBuyPrice =sellCostBuyPrice+1155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '75', storedetaildate = '2024-12-20 12:00:44' WHERE storedetailid = '15920';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15921', '1', '3', '1', '150338', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '4', '75', '2024-12-20 12:00:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36157;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('380','R3328', '150338', '1', '16325', '2', '450', '900', '0', '', '1', '2024-12-20 12:00:44', '16325', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36157-2,','1','1','0','0','450','900','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 380.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 380.00
        , lastbuyprice_withTax = 380, meanbuyprice_withTax = 380, lastbuyprice_withDiscountAndTax = 380
                where sellbilldetailid = 549218;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16325, '2024-12-20', 900, 760, 760
                    , 760, 760, 760, 760
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 760, 760, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+760
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+760, sellCostMeanBuyPrice = sellCostMeanBuyPrice+760
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+760, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+760
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+760
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+760
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+760
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 900, 760, 760
                    , 760, 760, 760, 760
                    , 0, 0, 0, 0
                    , 0, 0, 0, 760, 760, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+760
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+760, sellCostMeanBuyPrice = sellCostMeanBuyPrice+760
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+760, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+760
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+760
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+760
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+760
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '30', userid = '75', storedetaildate = '2024-12-20 12:00:44' WHERE storedetailid = '16324';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16325', '1', '2', '1', '150338', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32', '30', '75', '2024-12-20 12:00:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+5 where id = 36282;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('410','R3335', '150338', '1', '16410', '5', '470', '2350', '0', '', '1', '2024-12-20 12:00:44', '16410', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36282-5,','1','1','0','0','470','2350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
        , lastbuyprice_withTax = 410, meanbuyprice_withTax = 410, lastbuyprice_withDiscountAndTax = 410
                where sellbilldetailid = 549219;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16410, '2024-12-20', 2350, 2050, 2050
                    , 2050, 2050, 2050, 2050
                    , 0, 0, 0, 0
                    , 0, 0, 0, 5, 0, 2050, 2050, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2350, sellCostBuyPrice =sellCostBuyPrice+2050
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2050, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2050
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2050, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2050
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2050
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2050
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2050
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+5
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 2350, 2050, 2050
                    , 2050, 2050, 2050, 2050
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2050, 2050, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2350, sellCostBuyPrice =sellCostBuyPrice+2050
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2050, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2050
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2050, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2050
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2050
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2050
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2050
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 12:00:44' WHERE storedetailid = '16409';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16410', '1', '5', '1', '150338', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '1', '75', '2024-12-20 12:00:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 36169;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('545','H1625', '150338', '14', '16280', '3', '635', '1905', '0', '', '1', '2024-12-20 12:00:44', '16280', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36169-3,','1','1','0','0','635','1905','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 545.00 , meanbuyprice = 543.00, lastbuyprice_withDiscount = 545.00, meanbuyprice_withDiscount = 543.00
        , lastbuyprice_withTax = 545, meanbuyprice_withTax = 449, lastbuyprice_withDiscountAndTax = 545
                where sellbilldetailid = 549220;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16280, '2024-12-20', 1905, 1635, 1635
                    , 1629, 1635, 1629, 1620
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 1635, 1347, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1905, sellCostBuyPrice =sellCostBuyPrice+1635
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1635, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1629
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1635, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1629
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1635
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1347
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1905, 1635, 1635
                    , 1629, 1635, 1629, 1620
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1635, 1347, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1905, sellCostBuyPrice =sellCostBuyPrice+1635
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1635, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1629
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1635, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1629
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1635
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1347
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '75', storedetaildate = '2024-12-20 12:00:44' WHERE storedetailid = '16279';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16280', '1', '3', '1', '150338', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '13', '75', '2024-12-20 12:00:44','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150338', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 12:00:44', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150338', '17', '10291', '1', '66', '66', '0', '', '1', '2024-12-20 12:00:44', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','66','66','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 78 where clientid = 10763;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 6591, 5600, 5600
                    , 5594, 5600, 5594, 5585
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,5600, 5312, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+6591, sellCostBuyPrice =sellCostBuyPrice+5600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+5600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+5594
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+5600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+5594
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+5585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+5600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5312
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10763, '2024-12-20', 6591, 5600, 5600
                    , 5594, 5600, 5594, 5585
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,5600, 5312, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+6591, sellCostBuyPrice =sellCostBuyPrice+5600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+5600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+5594
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+5600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+5594
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+5585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+5600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5312
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 6591, 5600, 5600
                    , 5594, 5600, 5594, 5585, 5600, 5312)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+6591, netSellCostBuyPrice = netSellCostBuyPrice+5600
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+5600
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+5594
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+5600
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+5594
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+5585
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+5600
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+5312;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067653c7b432a8 and sellbillId = 150338 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:30:45";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 12:00:45", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:00:45', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:34:29";
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE programsettings SET companyname = 'BRAVO STORE', address = '8 شارع بورسعيد امام مستشفى السيد جلال', specializtion = 'Shoes ', phone = '01000464376', faxnumber = '0502232923', email = 'mrabozied@gt4it.com', website = 'www.gt4host.com', logo = '7e5a967475936eb131e45001c916f002.jpg', roundnumbers = '0', saveprinting = '0', deptprinting = '0', printingpapersize = '0', userid = '1', showPreviousPrice = '0', parcode = '0', priceing = '0', lastprice = '0', searchvalue = '1',clientsearchvalue = '3', updateproductprice = '0', allowfinsldelete = '0', updateclientprice = '0', `partition` = '0', taxcard = '332', commercialregistration = '3213123312', costcenter = '1', clinic = '1', workshop = '1', transport = '1', manufacturing = '0', masterCopy = '0' , dailyentrydate = '2020-04-18' ,updatefiledate = '2024-12-20',workerbetweenstores = '1',workshoptimeout = '24',drivertimeout = '3',currancy = 'جنيه',serial='7d1e8143a130fbea73dd3b9428a2caad8616ba42c98c2ee7a1bee8768760601b26945ac68358157bd4fc715be3f2049d90617f7a25078b4fb12d780f17ff8d26',allowdateedit = '1', clientcode = '1' ,clientserial = '1',timezone = 'Africa/Cairo' , expiredate ='1' , production ='1' , description='1' , service ='1' , date='1' , limitamount = '1' , measuringunit = '1' , print_amount = '0' , billid = '0' , precentages = '1' , realprice = '1' ,delegate_seller = '0' , storeserial = '1' ,clientfieldrequired ='0' , clientcodname='0' , colortype = '0' , nakdyOnly = '0' , nakdyKashf = '0' , discount_pres_direct = '0' , general_discount = '0' , sells_return = '0' ,scunitname ='0',vatValue = '0.00',syncstructure = '1',showPrevPrices = '0',isOpticProg='1',reportsPlusHours = '2' , showM5zon = '1',restaurantStoreId = '1',restuarantPrintTimeout = '8',sumSameProductForStore = '0', editAllPrice = '1', isCafe = '0' ,isRestaurent = '0' ,productDays = '0',thereIsRestTax = '0',restTaxVal = '0',restPrintLang = '0',taxNameFlag = '0',parcodeDigits = '5' ,specializedParcodeDigits = '7', clientDefaultDebtLimit = '10000' , clientDefaultDebtLimitControl = '0',usedParcode = '1' ,productbycodeimage = '' ,commentClient='تعليق على العميل ',Inventoryevaluation='first',Profitevaluation='first' , delivery='-2',premiums = '0',operationnumEdit = '0',noOfDecimalPlaces = '2',unReviewBills = '0', unReviewBillsPass = '123',billReviewNote = '',tamweenBakery = '0',three_months = '0',six_months = '0',twelve_months = '0',eighteen_months = '0',twentyfour_months = '0',thirty_months = '0',sixthirty_months = '0',fortytwo_months = '0',fortyeight_months = '0',mandobCollectionRatio='0',takeAwayClient = '0',restaurantServiceOn = ',-2,-1,1,',earlyrepayment = '0',visaPay = '0',headerPrint='',headerPrintSand='',printSand='0',makeDailyEntry='0',clientShowTawla='0',billRest='1',suppIsClientToo='0',isCarBill='0',expensesproduct='1',projectshownew='1',showparcode='1',changeBuyPriceChangeSellInBuyBillCtrl = '0',changeBuyPriceChangeSellInProductCtrl = '0',inventoryvaluation = '1',showBillCollectionSearch='1',incomeclient='1',showserial='1',editservice='1',showCurrency='0',qrerp='1',valueadded='0',qrcodesh='1',printfoot='',sellorder='1',numberprint='0',valueaddedbuy='0',simpleAddClientInBill='0',licenseNo='',maintenance='0',showPrevDiscount='0',vatvalueqr='0.13043479',imgprinthide='0',parcodeprinttype = 'C128A',parcodeprintwidth='160',parcodeprinttextsize='14',parcodeprintCurr='L.E',sizecolorDigits='3',searchBarcodeInBill='0',allowMobileLogin='0',lanAllowType='0',wanAllowType='0',sendBillToRestaurant='0',obgyPharmacyGroups='',updateProUnitPricesOnPriceUpdate='0',ebill='0',valueaddeddiscount='0',clientdetail='1',showPrevPricesRet='0',showPrevDiscountRet='0',eunitInTax='',showStoreToDetail='0',showBuyPriceAtProductddl='0',specialexpenses='1',ratioshow='0',defaultUnitPriceAtBill='0',rulers='1',quantitynew='0',showBillOperationSearch='0',obygyFolder='',clientsell='0',
                preorderperiod='0',useListPrice='0',ebillclient='0',importproduct='1',realestateunits='0',expensesupplier='0',changeOrderproduct='0',searchlimit='0',typebill='',roundnumbersbilltotal='0',noOfDecimalPlacesBillTotal='2',dailyEntryCostprice='first',storeRecieveType='0',clientPhoneReq='0',addServiceToBill='0',realestatedev='1',showprice4='0',showprice5='0',showprice6='0',showprice7='0',showprice8='0',showpriceall='1',showpricehalf='1',showpriceunit='1',showbillstatus='0',showbilldeliverydate='0',enablequantityfractions='0',addclienttoproduct='0',closingcustomeraccount='0',serial2='9c2d4cf4cf5d4e24d5070164705832c3a5d1287f641a2960e48e04ae57a2ad0a5441322ca7cf34efd63003fdb348adbd0b61197c7c87d8dd5bc298c352482bc6',
                shownameE='0',showprocode='0',showpartnumber='0',showtype='0',showcompany='0',showweight='0',showorigin='0',showhscode='0',showexpire='0',showgrantduration='0',showonline='0',showminappear='0',showonlinecat='0',showsellpercentage='0',showbuydiscount='0',preparingStore='1',sellordername='0',showsearchfilter='0',unitPriceAtsalesreport='0',medExCat='0',laterNakdiClientId='0',headerPrint12Right='',headerPrint12Left='',halfPriceStart='0',allPriceStart='0',checkretsellclient='2' WHERE programsettingsid = '1';
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:38:24";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:08:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:08:24', '104', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:38:44";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:08:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:08:44', '104', 'add', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'دنيا', '', '150', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '6820',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6970.00','150', '1', '1', 'إضافة مصروف', '25895', '6820', '2024-12-20 12:08:44', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'دنيا', expensesdetails = '', expensesValue = '150.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25895';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:38:45";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:08:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:08:45', '104', 'sucess', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:38:46";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:08:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:08:46', '104', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE userid = 104;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:39:07";
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:41:05";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:11:05", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 12:11:05', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:41:06";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:41:38";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:11:38", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:11:38', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:42:56";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:12:56", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 12:12:56', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:43:07";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:13:07", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 12:13:07', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE userid = 9;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:47:31";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:17:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 12:17:31', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:47:32";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:47:34";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:17:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:17:34', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:47:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:17:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:17:46', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'الاء عماد ', '', '50', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '6770',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6820.00','50', '1', '1', 'إضافة مصروف', '25896', '6770', '2024-12-20 12:17:46', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'الاء عماد ', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25896';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:47:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:17:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:17:46', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:47:48";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:17:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:17:48', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:48:11";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:18:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:18:11', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:49:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:19:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:19:28', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067654463eff71
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:18:11', '067654463eff71', '1', '0.00', '0', '0', '1', '900.00', '900', '900', '0', '1', '2024-12-20 12:19:28', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','900','0','','0','0','900','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150339', '0', '2024-12-20 12:19:28', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '900', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 12:18:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36203;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('335','07221', '150339', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-20 12:19:28', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36203-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 549223;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16279, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '65', userid = '104', storedetaildate = '2024-12-20 12:19:28' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150339', 'اضافة فاتورة مبيعات', 'sellbillController.php', '66', '65', '104', '2024-12-20 12:19:28','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35824;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','07174', '150339', '5', '16240', '1', '300', '300', '0', '', '1', '2024-12-20 12:19:28', '16240', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35824-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549224;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16240, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-20 12:19:28' WHERE storedetailid = '16239';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16240', '1', '1', '1', '150339', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-20 12:19:28','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36365;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','07293', '150339', '5', '16434', '1', '200', '200', '0', '', '1', '2024-12-20 12:19:28', '16434', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36365-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549225;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16434, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-20 12:19:28' WHERE storedetailid = '16433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16434', '1', '1', '1', '150339', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-20 12:19:28','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7670',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6770','900', '0', '1', 'اضافة فاتورة مبيعات', '150339', '7670', '2024-12-20 12:19:28', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 97 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 900, 720, 720
                    , 720, 720, 720, 720
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,720, 708, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+720
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+720, sellCostMeanBuyPrice = sellCostMeanBuyPrice+720
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+720, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+720
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+720
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+720
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+708
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 900, 720, 720
                    , 720, 720, 720, 720
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,720, 708, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+720
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+720, sellCostMeanBuyPrice = sellCostMeanBuyPrice+720
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+720, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+720
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+720
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+720
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+708
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 900, 720, 720
                    , 720, 720, 720, 720, 720, 708)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+900, netSellCostBuyPrice = netSellCostBuyPrice+720
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+720
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+720
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+720
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+720
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+720
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+720
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+708;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067654463eff71 and sellbillId = 150339 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:49:29";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:19:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:19:29', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:50:17";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:20:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 12:20:17', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:51:58";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:21:58", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:21:58', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:55:28";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 12:25:28", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:25:28', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765404d8cc2d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10142,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:00:45', '06765404d8cc2d', '10142', '20.00', '288', '0', '1', '268.00', '268', '0', '268', '1', '2024-12-20 12:25:28', '', '75', '0', 'رانا نبيل 100', '2', '1', '3', '83', 'رانا نبيل 100', '2' ,'0','','','','','-1','0','0','0','0','0','268','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '288', userid = '75' WHERE clientid = '10142';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10142','20.00','268','0','اضافة فاتورة مبيعات','150340', '288', '2024-12-20 12:25:28', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '268', '0', null, '0', null, null,'', '0','1','1','268','1','2024-12-20 12:00:45','0','0');
UPDATE client SET  inUse = 0 where clientid = 10142;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32064;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06343', '150340', '5', '14424', '1', '265', '265', '0', '', '1', '2024-12-20 12:25:28', '14424', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32064-1,','1','1','0','0','265','265','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 466.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 466.00
        
                where sellbilldetailid = 549226;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14424, '2024-12-20', 265, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+265, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 265, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+265, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 12:25:28' WHERE storedetailid = '14423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14424', '1', '1', '1', '150340', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 12:25:28','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150340', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-20 12:25:28', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','3','3','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 83 where clientid = 10142;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 268, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+268, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10142, '2024-12-20', 268, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+268, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 268, 225, 225
                    , 466, 225, 466, 225, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+268, netSellCostBuyPrice = netSellCostBuyPrice+225
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+225
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+466
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+225
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+466
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+225
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765404d8cc2d and sellbillId = 150340 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:55:28";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 12:25:28", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:25:28', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:56:44";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:26:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:26:44', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:57:05";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:27:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:27:05', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'محمد اشرف', '', '50', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '7620',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7670.00','50', '1', '1', 'إضافة مصروف', '25897', '7620', '2024-12-20 12:27:06', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد اشرف', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25897';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:57:06";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:27:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:27:06', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 08:57:08";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:27:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:27:08', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:02:38";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:32:38", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:32:38', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:03:12";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:33:12", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:33:12', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676547c6ea2dc
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4825,@clientdebt,@clientname,@treeIdis);
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 12:32:38', '0676547c6ea2dc', '4825', '1652.00', '1367', '0', '1', '285', '285', '0', '-285', '1', '2024-12-20 12:33:13', '', '101', '0', 'رشا عادل U41','2', '1', '5', '91', 'رشا عادل U41', '1', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '1367', userid = '101' WHERE clientid = '4825';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4825','1652.00','285','1','اضافة فاتورة مردوات مبيعات','16845', '1367', '2024-12-20 12:33:13', '101', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '285', '0', null, '0', null, null,'', '0','1','1','285','1','2024-12-20 12:32:38','0','0');
UPDATE client SET  inUse = 0 where clientid = 4825;
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('230.00', 'R3279', '16845', '1', '15865', '1', '285', '285', '0', '', '1', '0', '15865', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','285','285','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where returnsellbilldetailid = 22034;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15865, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 285, 230, 230, 230
                    , 230, 230, 230, 0, 1, 0, 0, 230, 230)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+285, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+230
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+230
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+230
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 285, 230, 230, 230
                    , 230, 230, 230, 0, 0, 230, 230)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+285, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+230
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+230
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+230;
UPDATE storedetail SET  productquantity = '5', userid = '101', storedetaildate = '2024-12-20 12:33:13' WHERE storedetailid = '15864';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15865', '1', '1', '0', '16845', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '4', '5', '101', '2024-12-20 12:33:13','0','0');
UPDATE client SET  delegateid = 91 where clientid = 4825;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 285, 230, 230, 230
                    , 230, 230, 230 ,0, 0, 230, 230)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+285, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+230
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+230
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+230;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4825, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 285, 230, 230, 230
                    , 230, 230, 230 ,0, 0, 230, 230)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+285, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+230
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+230
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+230;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -285, -230, -230
                    , -230, -230, -230, -230, -230, -230)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-285, netSellCostBuyPrice = netSellCostBuyPrice+-230
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-230
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-230
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-230
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-230
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-230
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-230
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-230;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676547c6ea2dc and sellbillId = 16845 and returnsellbillId = 16845
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:03:13";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:33:13", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:33:13', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:03:18";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:03:26";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:03:52";
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:04:02";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 12:34:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 12:34:02', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:04:02";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:04:06";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 12:34:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 12:34:06', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:04:30";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 12:34:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 12:34:30', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:09:18";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:39:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:39:18', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:09:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:39:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:39:27', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'محمد عبدة', '', '100', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '7520',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7620.00','100', '1', '1', 'إضافة مصروف', '25898', '7520', '2024-12-20 12:39:27', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد عبدة', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25898';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:09:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:39:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:39:28', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:09:30";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:39:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:39:30', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:11:56";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 12:41:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 12:41:56', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:12:18";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 12:42:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 12:42:18', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247834
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1055,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 12:42:18', userid = '2' WHERE clientid = '1055';
UPDATE client SET  inUse = 0 where clientid = 1055;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1055','1081.00','1081','1','ايصال تحصيل (( قبض من عميل ))','247834', '0', '2024-12-20 12:41:56', '2', 'clientPayedDeptController.php', '   ', '1081', '0', null, '0', null, null,'', '-1','1','1','1081','1','','3617','0');
UPDATE save SET  savecurrentvalue = '77572.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('76491.50','1081', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247834', '77572.5', '2024-12-20 12:42:18', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1081', '1081', '2024-12-20', '2', '0', '0', '2024-12-20 12:42:18','اضافة ايصال سداد للعميل هالة محمد السويس 14','1','0','0','0','247834','clientPayedDeptController.php?do=show&id=247834');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122276', '-1', '1081', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1081', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122276', '-1', '1081', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1081', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '1055', clientdebtchangebefore = '1081.000', clientdebtchangeamount = '1081.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247834', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 12:41:56', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1081.00',discount='', reciptid='0', dailyentryid = '122276',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1081',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247834';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247834 -clientdebtchangeId = 247834
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:12:19";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 12:42:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 12:42:19', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:12:44";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 12:42:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 12:42:44', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247835
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3177,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-1' , clientdate = '2024-12-20 12:42:44', userid = '2' WHERE clientid = '3177';
UPDATE client SET  inUse = 0 where clientid = 3177;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3177','734.00','735','1','ايصال تحصيل (( قبض من عميل ))','247835', '-1', '2024-12-20 12:42:19', '2', 'clientPayedDeptController.php', '   ', '735', '0', null, '0', null, null,'', '-1','1','1','735','1','','3618','0');
UPDATE save SET  savecurrentvalue = '78307.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('77572.50','735', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247835', '78307.5', '2024-12-20 12:42:44', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '735', '735', '2024-12-20', '2', '0', '0', '2024-12-20 12:42:44','اضافة ايصال سداد للعميل سهيلة سلطان B746','1','0','0','0','247835','clientPayedDeptController.php?do=show&id=247835');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122277', '-1', '735', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '735', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122277', '-1', '735', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-735', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '3177', clientdebtchangebefore = '734.000', clientdebtchangeamount = '735.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247835', clientdebtchangeafter = '-1.000', clientdebtchangedate = '2024-12-20 12:42:19', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '735.00',discount='', reciptid='0', dailyentryid = '122277',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='735',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247835';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247835 -clientdebtchangeId = 247835
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:12:45";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 12:42:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 12:42:45', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:12:48";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:42:48", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:42:48', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676542dad96b8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1104,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:11:38', '0676542dad96b8', '1104', '-388.00', '6987', '420', '1', '7795.00', '7375', '0', '7375', '1', '2024-12-20 12:42:48', '', '101', '0', 'خالد توينز K3', '2', '1', '3', '79', 'خالد توينز K3', '21' ,'0','','','','','-1','0','0','0','0','0','7375','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '6987', userid = '101' WHERE clientid = '1104';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1104','-388.00','7375','0','اضافة فاتورة مبيعات','150341', '6987', '2024-12-20 12:42:48', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '7375', '0', null, '0', null, null,'', '0','1','1','7375','1','2024-12-20 12:11:38','0','0');
UPDATE client SET  inUse = 0 where clientid = 1104;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35423;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','06959', '150341', '5', '15856', '1', '200', '200', '0', '', '1', '2024-12-20 12:42:48', '15856', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35423-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549228;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15856, '2024-12-20', 189.22386144965, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+189.22386144965, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 189.22386144965, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+189.22386144965, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '101', storedetaildate = '2024-12-20 12:42:48' WHERE storedetailid = '15855';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15856', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '101', '2024-12-20 12:42:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36351;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('220','H1464', '150341', '14', '15853', '1', '280', '280', '0', '', '1', '2024-12-20 12:42:48', '15853', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36351-1,','1','1','0','0','280','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
        , lastbuyprice_withTax = 220, meanbuyprice_withTax = 220, lastbuyprice_withDiscountAndTax = 220
                where sellbilldetailid = 549229;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15853, '2024-12-20', 264.91340602951, 220, 220
                    , 220, 220, 220, 220.79
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+264.91340602951, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+220
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+220
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 264.91340602951, 220, 220
                    , 220, 220, 220, 220.79
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+264.91340602951, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+220
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+220
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '17', userid = '101', storedetaildate = '2024-12-20 12:42:48' WHERE storedetailid = '15852';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15853', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '101', '2024-12-20 12:42:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36349;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('185','H1619', '150341', '14', '16298', '1', '250', '250', '0', '', '1', '2024-12-20 12:42:48', '16298', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36349-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 185.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 185.00
        , lastbuyprice_withTax = 185, meanbuyprice_withTax = 185, lastbuyprice_withDiscountAndTax = 185
                where sellbilldetailid = 549230;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16298, '2024-12-20', 236.52982681206, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 185, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+236.52982681206, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+185
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+185
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 236.52982681206, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0, 185, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+236.52982681206, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+185
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+185
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '25', userid = '101', storedetaildate = '2024-12-20 12:42:48' WHERE storedetailid = '16297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16298', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '101', '2024-12-20 12:42:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36459;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('525','H1666', '150341', '14', '16470', '1', '650', '650', '0', '', '1', '2024-12-20 12:42:48', '16470', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36459-1,','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 525.00 , meanbuyprice = 525.00, lastbuyprice_withDiscount = 525.00, meanbuyprice_withDiscount = 525.00
        , lastbuyprice_withTax = 525, meanbuyprice_withTax = 525, lastbuyprice_withDiscountAndTax = 525
                where sellbilldetailid = 549231;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16470, '2024-12-20', 614.97754971135, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+614.97754971135, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 614.97754971135, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+614.97754971135, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 12:42:48' WHERE storedetailid = '16469';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16470', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '101', '2024-12-20 12:42:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36348;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('400','H1661', '150341', '14', '16430', '2', '500', '1000', '0', '', '1', '2024-12-20 12:42:48', '16430', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36348-2,','1','1','0','0','500','1000','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549232;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16430, '2024-12-20', 946.11930724824, 800, 800
                    , 800, 800, 800, 800
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 800, 800, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+946.11930724824, sellCostBuyPrice =sellCostBuyPrice+800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+800, sellCostMeanBuyPrice = sellCostMeanBuyPrice+800
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+800
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+800
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+800
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+800
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 946.11930724824, 800, 800
                    , 800, 800, 800, 800
                    , 0, 0, 0, 0
                    , 0, 0, 0, 800, 800, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+946.11930724824, sellCostBuyPrice =sellCostBuyPrice+800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+800, sellCostMeanBuyPrice = sellCostMeanBuyPrice+800
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+800
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+800
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+800
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+800
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '101', storedetaildate = '2024-12-20 12:42:48' WHERE storedetailid = '16429';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16430', '1', '2', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '14', '101', '2024-12-20 12:42:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36098;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('570','H1603', '150341', '14', '16318', '1', '650', '650', '0', '', '1', '2024-12-20 12:42:48', '16318', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36098-1,','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 570.00 , meanbuyprice = 569.00, lastbuyprice_withDiscount = 570.00, meanbuyprice_withDiscount = 569.00
        , lastbuyprice_withTax = 570, meanbuyprice_withTax = 568, lastbuyprice_withDiscountAndTax = 570
                where sellbilldetailid = 549233;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16318, '2024-12-20', 614.97754971135, 570, 570
                    , 569, 570, 569, 570
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 570, 568, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+614.97754971135, sellCostBuyPrice =sellCostBuyPrice+570
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+570, sellCostMeanBuyPrice = sellCostMeanBuyPrice+569
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+570, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+569
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+570
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+570
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+568
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 614.97754971135, 570, 570
                    , 569, 570, 569, 570
                    , 0, 0, 0, 0
                    , 0, 0, 0, 570, 568, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+614.97754971135, sellCostBuyPrice =sellCostBuyPrice+570
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+570, sellCostMeanBuyPrice = sellCostMeanBuyPrice+569
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+570, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+569
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+570
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+570
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+568
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '101', storedetaildate = '2024-12-20 12:42:48' WHERE storedetailid = '16317';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16318', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '101', '2024-12-20 12:42:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36417;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('630','H1647', '150341', '14', '16455', '1', '730', '730', '0', '', '1', '2024-12-20 12:42:48', '16455', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36417-1,','1','1','0','0','730','730','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 630.00 , meanbuyprice = 630.00, lastbuyprice_withDiscount = 630.00, meanbuyprice_withDiscount = 630.00
        , lastbuyprice_withTax = 630, meanbuyprice_withTax = 630, lastbuyprice_withDiscountAndTax = 630
                where sellbilldetailid = 549234;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16455, '2024-12-20', 690.66709429121, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+690.66709429121, sellCostBuyPrice =sellCostBuyPrice+630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+630
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 690.66709429121, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+690.66709429121, sellCostBuyPrice =sellCostBuyPrice+630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+630
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '101', storedetaildate = '2024-12-20 12:42:48' WHERE storedetailid = '16454';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16455', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '101', '2024-12-20 12:42:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35830;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('440','07176', '150341', '5', '16244', '1', '480', '480', '0', '', '1', '2024-12-20 12:42:48', '16244', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35830-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 440.00 , meanbuyprice = 440.00, lastbuyprice_withDiscount = 440.00, meanbuyprice_withDiscount = 440.00
        , lastbuyprice_withTax = 440, meanbuyprice_withTax = 440, lastbuyprice_withDiscountAndTax = 440
                where sellbilldetailid = 549235;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16244, '2024-12-20', 454.13726747915, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+454.13726747915, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+440
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 454.13726747915, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+454.13726747915, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+440
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '101', storedetaildate = '2024-12-20 12:42:48' WHERE storedetailid = '16243';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16244', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '101', '2024-12-20 12:42:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36142;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07226', '150341', '5', '16294', '2', '210', '420', '0', '', '1', '2024-12-20 12:42:48', '16294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36142-2,','1','1','0','0','210','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 151.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 151.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 153, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549236;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16294, '2024-12-20', 397.37010904426, 310, 310
                    , 302, 310, 302, 306.24
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 310, 306, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+397.37010904426, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+306.24
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+306
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 397.37010904426, 310, 310
                    , 302, 310, 302, 306.24
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 306, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+397.37010904426, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+306.24
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+306
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '72', userid = '101', storedetaildate = '2024-12-20 12:42:48' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '2', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '74', '72', '101', '2024-12-20 12:42:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36109;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('160','07269', '150341', '5', '16378', '2', '220', '440', '0', '', '1', '2024-12-20 12:42:48', '16378', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36109-2,','1','1','0','0','220','440','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 160, lastbuyprice_withDiscountAndTax = 160
                where sellbilldetailid = 549237;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16378, '2024-12-20', 416.29249518922, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+416.29249518922, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+320
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+320
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 416.29249518922, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+416.29249518922, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+320
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+320
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '101', storedetaildate = '2024-12-20 12:42:48' WHERE storedetailid = '16377';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16378', '1', '2', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '7', '101', '2024-12-20 12:42:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36315;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07284', '150341', '5', '16415', '1', '200', '200', '0', '', '1', '2024-12-20 12:42:48', '16415', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36315-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549238;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16415, '2024-12-20', 189.22386144965, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+189.22386144965, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 189.22386144965, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+189.22386144965, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '18', userid = '101', storedetaildate = '2024-12-20 12:42:48' WHERE storedetailid = '16414';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16415', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '101', '2024-12-20 12:42:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35992;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('230','07252', '150341', '5', '16337', '1', '280', '280', '0', '', '1', '2024-12-20 12:42:49', '16337', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35992-1,','1','1','0','0','280','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where sellbilldetailid = 549239;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16337, '2024-12-20', 264.91340602951, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+264.91340602951, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 264.91340602951, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+264.91340602951, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '32', userid = '101', storedetaildate = '2024-12-20 12:42:49' WHERE storedetailid = '16336';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16337', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '33', '32', '101', '2024-12-20 12:42:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33646;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('320','06685', '150341', '5', '15192', '1', '360', '360', '0', '', '1', '2024-12-20 12:42:49', '15192', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33646-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
        
                where sellbilldetailid = 549240;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15192, '2024-12-20', 340.60295060936, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340.60295060936, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 340.60295060936, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340.60295060936, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '101', storedetaildate = '2024-12-20 12:42:49' WHERE storedetailid = '15191';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15192', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '101', '2024-12-20 12:42:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35821;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('235','07085', '150341', '5', '16091', '1', '285', '285', '0', '', '1', '2024-12-20 12:42:49', '16091', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35821-1,','1','1','0','0','285','285','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 235.00
        , lastbuyprice_withTax = 235, meanbuyprice_withTax = 235, lastbuyprice_withDiscountAndTax = 235
                where sellbilldetailid = 549241;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16091, '2024-12-20', 269.64400256575, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+269.64400256575, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+235
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 269.64400256575, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+269.64400256575, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+235
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '101', storedetaildate = '2024-12-20 12:42:49' WHERE storedetailid = '16090';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16091', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '101', '2024-12-20 12:42:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36355;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','H1522', '150341', '14', '15967', '1', '360', '360', '0', '', '1', '2024-12-20 12:42:49', '15967', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36355-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 295.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 295.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 549242;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15967, '2024-12-20', 340.60295060936, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340.60295060936, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 340.60295060936, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340.60295060936, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '34', userid = '101', storedetaildate = '2024-12-20 12:42:49' WHERE storedetailid = '15966';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15967', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '35', '34', '101', '2024-12-20 12:42:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36128;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07264', '150341', '5', '16385', '1', '200', '200', '0', '', '1', '2024-12-20 12:42:49', '16385', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36128-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 70, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549243;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16385, '2024-12-20', 189.22386144965, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 70, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+189.22386144965, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+70
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 189.22386144965, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 70, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+189.22386144965, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+70
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '101', storedetaildate = '2024-12-20 12:42:49' WHERE storedetailid = '16384';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16385', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '101', '2024-12-20 12:42:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36003;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07220', '150341', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-20 12:42:49', '16293', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36003-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549244;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16293, '2024-12-20', 189.22386144965, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+189.22386144965, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 189.22386144965, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+189.22386144965, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '34', userid = '101', storedetaildate = '2024-12-20 12:42:49' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '35', '34', '101', '2024-12-20 12:42:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36399;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('745','07305', '150341', '5', '16454', '1', '810', '810', '0', '', '1', '2024-12-20 12:42:49', '16454', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36399-1,','1','1','0','0','810','810','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 735.00 , meanbuyprice = 737.00, lastbuyprice_withDiscount = 735.00, meanbuyprice_withDiscount = 737.00
        , lastbuyprice_withTax = 735, meanbuyprice_withTax = 739, lastbuyprice_withDiscountAndTax = 735
                where sellbilldetailid = 549245;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16454, '2024-12-20', 766.35663887107, 735, 735
                    , 737, 735, 737, 740
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 735, 739, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+766.35663887107, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+737
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+737
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+740
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+739
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 766.35663887107, 735, 735
                    , 737, 735, 737, 740
                    , 0, 0, 0, 0
                    , 0, 0, 0, 735, 739, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+766.35663887107, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+737
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+737
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+740
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+739
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '22', userid = '101', storedetaildate = '2024-12-20 12:42:49' WHERE storedetailid = '16453';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16454', '1', '1', '1', '150341', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '101', '2024-12-20 12:42:49','0','0');
UPDATE client SET  delegateid = 79 where clientid = 1104;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 7375, 6390, 6390
                    , 6383, 6390, 6383, 6392.03
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6070, 5998, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7375, sellCostBuyPrice =sellCostBuyPrice+6390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6383
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6383
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6392.03
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+6070
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5998
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1104, '2024-12-20', 7375, 6390, 6390
                    , 6383, 6390, 6383, 6392.03
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6070, 5998, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7375, sellCostBuyPrice =sellCostBuyPrice+6390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6383
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6383
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6392.03
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+6070
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5998
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 7375, 6390, 6390
                    , 6383, 6390, 6383, 6392.03, 6070, 5998)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+7375, netSellCostBuyPrice = netSellCostBuyPrice+6390
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+6390
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+6383
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+6390
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+6383
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+6392.03
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+6070
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+5998;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676542dad96b8 and sellbillId = 150341 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:12:50";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:42:50", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:42:50', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:13:03";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 12:43:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 12:43:03', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247836
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10744,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-1' , clientdate = '2024-12-20 12:43:03', userid = '2' WHERE clientid = '10744';
UPDATE client SET  inUse = 0 where clientid = 10744;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10744','1354.00','1355','1','ايصال تحصيل (( قبض من عميل ))','247836', '-1', '2024-12-20 12:42:45', '2', 'clientPayedDeptController.php', '   ', '1355', '0', null, '0', null, null,'', '-1','1','1','1355','1','','3619','0');
UPDATE save SET  savecurrentvalue = '79662.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('78307.50','1355', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247837', '79662.5', '2024-12-20 12:43:03', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1355', '1355', '2024-12-20', '2', '0', '0', '2024-12-20 12:43:03','اضافة ايصال سداد للعميل هاجر شبانة 25','1','0','0','0','247837','clientPayedDeptController.php?do=show&id=247837');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122278', '-1', '1355', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1355', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122278', '12563', '1355', '','0');
UPDATE accountstree SET name = 'هاجر شبانة 25', customName = 'هاجر شبانة 25', customNameEn = 'هاجر شبانة 25', nameEn = 'هاجر شبانة 25', parent = '58', accountNature = '0', theValue = '-1355', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-18 18:14:43' WHERE id = '12563';
UPDATE clientdebtchange SET clientid = '10744', clientdebtchangebefore = '1354.000', clientdebtchangeamount = '1355.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247836', clientdebtchangeafter = '-1.000', clientdebtchangedate = '2024-12-20 12:42:45', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1355.00',discount='', reciptid='0', dailyentryid = '122278',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1355',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247837';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247836 -clientdebtchangeId = 247837
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:13:03";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 12:43:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 12:43:03', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:15:05";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:45:05", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:45:05', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067654a2a414a8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5737,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:42:50', '067654a2a414a8', '5737', '6.00', '642', '0', '1', '636.00', '636', '0', '636', '1', '2024-12-20 12:45:05', '', '101', '0', 'مريم حافظ 41', '2', '1', '3', '88', 'مريم حافظ 41', '4' ,'0','','','','','-1','0','0','0','0','0','636','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '642', userid = '101' WHERE clientid = '5737';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5737','6.00','636','0','اضافة فاتورة مبيعات','150342', '642', '2024-12-20 12:45:05', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '636', '0', null, '0', null, null,'', '0','1','1','636','1','2024-12-20 12:42:50','0','0');
UPDATE client SET  inUse = 0 where clientid = 5737;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36469;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('335','07221', '150342', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-20 12:45:05', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36469-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 549246;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16279, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '64', userid = '101', storedetaildate = '2024-12-20 12:45:05' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150342', 'اضافة فاتورة مبيعات', 'sellbillController.php', '65', '64', '101', '2024-12-20 12:45:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36142;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07226', '150342', '5', '16294', '1', '210', '210', '0', '', '1', '2024-12-20 12:45:05', '16294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36142-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 151.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 151.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 153, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549247;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16294, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '71', userid = '101', storedetaildate = '2024-12-20 12:45:05' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '1', '150342', 'اضافة فاتورة مبيعات', 'sellbillController.php', '72', '71', '101', '2024-12-20 12:45:05','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150342', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 12:45:05', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150342', '17', '10291', '1', '6', '6', '0', '', '1', '2024-12-20 12:45:06', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','6','6','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 88 where clientid = 5737;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 636, 490, 490
                    , 486, 490, 486, 488.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,490, 476, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+636, sellCostBuyPrice =sellCostBuyPrice+490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+490, sellCostMeanBuyPrice = sellCostMeanBuyPrice+486
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+490, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+486
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+488.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+490
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+476
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (5737, '2024-12-20', 636, 490, 490
                    , 486, 490, 486, 488.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,490, 476, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+636, sellCostBuyPrice =sellCostBuyPrice+490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+490, sellCostMeanBuyPrice = sellCostMeanBuyPrice+486
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+490, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+486
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+488.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+490
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+476
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 636, 490, 490
                    , 486, 490, 486, 488.12, 490, 476)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+636, netSellCostBuyPrice = netSellCostBuyPrice+490
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+490
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+486
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+490
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+486
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+488.12
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+490
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+476;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067654a2a414a8 and sellbillId = 150342 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:15:06";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:45:06", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:45:06', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:15:10";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:45:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:45:10', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:17:05";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:47:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:47:05', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067654ab66d865
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:45:10', '067654ab66d865', '1', '0.00', '0', '0', '1', '805.00', '805', '805', '0', '1', '2024-12-20 12:47:05', '', '104', '0', 'نقدي', '1', '0', '3', '25', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','805','0','','0','0','805','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150343', '0', '2024-12-20 12:47:05', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '805', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 12:45:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36358;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06603', '150343', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-20 12:47:05', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36358-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 226.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 226.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 227, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549250;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15038, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '52', userid = '104', storedetaildate = '2024-12-20 12:47:05' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '150343', 'اضافة فاتورة مبيعات', 'sellbillController.php', '53', '52', '104', '2024-12-20 12:47:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36298;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('215','H1470', '150343', '14', '15887', '1', '280', '280', '0', '', '1', '2024-12-20 12:47:05', '15887', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36298-1,','1','1','0','0','280','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 215.00 , meanbuyprice = 169.00, lastbuyprice_withDiscount = 215.00, meanbuyprice_withDiscount = 169.00
        , lastbuyprice_withTax = 215, meanbuyprice_withTax = 123, lastbuyprice_withDiscountAndTax = 215
                where sellbilldetailid = 549251;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15887, '2024-12-20', 280, 215, 215
                    , 169, 215, 169, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 215, 123, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+169
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+169
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+123
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 280, 215, 215
                    , 169, 215, 169, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 215, 123, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+169
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+169
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+123
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '104', storedetaildate = '2024-12-20 12:47:05' WHERE storedetailid = '15886';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15887', '1', '1', '1', '150343', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-20 12:47:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30950;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('340','06142', '150343', '5', '13901', '1', '235', '235', '0', '', '1', '2024-12-20 12:47:05', '13901', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30950-1,','1','1','0','0','235','235','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 340.00 , meanbuyprice = 1020.00, lastbuyprice_withDiscount = 340.00, meanbuyprice_withDiscount = 1020.00
        
                where sellbilldetailid = 549252;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13901, '2024-12-20', 235, 340, 340
                    , 1020, 340, 1020, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1020
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1020
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 235, 340, 340
                    , 1020, 340, 1020, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1020
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1020
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '104', storedetaildate = '2024-12-20 12:47:05' WHERE storedetailid = '13900';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13901', '1', '1', '1', '150343', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-20 12:47:05','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '8325',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7520','805', '0', '1', 'اضافة فاتورة مبيعات', '150343', '8325', '2024-12-20 12:47:05', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 25 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 805, 780, 780
                    , 1415, 780, 1415, 790.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,440, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+805, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1415
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1415
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+790.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 805, 780, 780
                    , 1415, 780, 1415, 790.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,440, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+805, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1415
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1415
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+790.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 805, 780, 780
                    , 1415, 780, 1415, 790.95, 440, 350)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+805, netSellCostBuyPrice = netSellCostBuyPrice+780
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+780
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1415
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+780
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1415
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+790.95
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+440
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+350;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067654ab66d865 and sellbillId = 150343 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:17:05";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:47:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:47:05', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:17:25";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:47:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:47:25', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:17:34";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:47:34", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:47:34', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067654ab2b85ec
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1590,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:45:06', '067654ab2b85ec', '1590', '0.00', '1121', '0', '1', '1121.00', '1121', '0', '1121', '1', '2024-12-20 12:47:34', '', '101', '0', 'دعاء محمود u25', '2', '1', '3', '88', 'دعاء محمود u25', '5' ,'0','','','','','-1','0','0','0','0','0','1121','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1121', userid = '101' WHERE clientid = '1590';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1590','0.00','1121','0','اضافة فاتورة مبيعات','150344', '1121', '2024-12-20 12:47:34', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1121', '0', null, '0', null, null,'', '0','1','1','1121','1','2024-12-20 12:45:06','0','0');
UPDATE client SET  inUse = 0 where clientid = 1590;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36469;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('335','07221', '150344', '5', '16279', '2', '400', '800', '0', '', '1', '2024-12-20 12:47:34', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36469-2,','1','1','0','0','400','800','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 549253;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16279, '2024-12-20', 800, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 670, 646, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+670
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+670, sellCostMeanBuyPrice = sellCostMeanBuyPrice+670
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+670, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+670
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+670
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+670
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+646
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 800, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0, 670, 646, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+670
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+670, sellCostMeanBuyPrice = sellCostMeanBuyPrice+670
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+670, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+670
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+670
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+670
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+646
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '62', userid = '101', storedetaildate = '2024-12-20 12:47:34' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '2', '1', '150344', 'اضافة فاتورة مبيعات', 'sellbillController.php', '64', '62', '101', '2024-12-20 12:47:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36358;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06603', '150344', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-20 12:47:34', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36358-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 226.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 226.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 227, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549254;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15038, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '51', userid = '101', storedetaildate = '2024-12-20 12:47:34' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '150344', 'اضافة فاتورة مبيعات', 'sellbillController.php', '52', '51', '101', '2024-12-20 12:47:34','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150344', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 12:47:34', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150344', '17', '10291', '1', '11', '11', '0', '', '1', '2024-12-20 12:47:34', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','11','11','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 88 where clientid = 1590;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1121, 895, 895
                    , 896, 895, 896, 905.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,895, 873, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1121, sellCostBuyPrice =sellCostBuyPrice+895
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+895, sellCostMeanBuyPrice = sellCostMeanBuyPrice+896
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+895, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+896
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+905.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+895
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+873
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1590, '2024-12-20', 1121, 895, 895
                    , 896, 895, 896, 905.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,895, 873, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1121, sellCostBuyPrice =sellCostBuyPrice+895
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+895, sellCostMeanBuyPrice = sellCostMeanBuyPrice+896
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+895, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+896
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+905.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+895
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+873
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1121, 895, 895
                    , 896, 895, 896, 905.95, 895, 873)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1121, netSellCostBuyPrice = netSellCostBuyPrice+895
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+895
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+896
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+895
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+896
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+905.95
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+895
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+873;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067654ab2b85ec and sellbillId = 150344 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:17:35";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 12:47:35", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:47:35', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:17:37";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:47:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:47:37', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'عمر', '', '100', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '8225',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8325.00','100', '1', '1', 'إضافة مصروف', '25899', '8225', '2024-12-20 12:47:37', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'عمر', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25899';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:17:38";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:47:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:47:38', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:17:40";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:47:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:47:40', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:18:11";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:48:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:48:11', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:18:13";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:48:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:48:13', '104', 'showDetail', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150344');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:18:16";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:48:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 12:48:16', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:18:21";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:48:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:48:21', '104', 'showDetail', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150343');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:18:27";
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:18:27";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:18:36";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:48:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:48:36', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:19:07";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 12:49:07", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 12:49:07', '101', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:19:08";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:19:24";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:49:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:49:24', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:19:26";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 12:49:26", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:49:26', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:19:34";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:49:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:49:34', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'سلمي', '', '50', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '8175',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8225.00','50', '1', '1', 'إضافة مصروف', '25900', '8175', '2024-12-20 12:49:34', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'سلمي', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25900';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:19:35";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:49:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:49:35', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:19:37";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:49:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:49:37', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:19:38";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 12:49:38", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:49:38', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:19:39";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:49:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:49:39', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:19:53";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:49:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:49:53', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'رضا', '', '50', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '8125',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8175.00','50', '1', '1', 'إضافة مصروف', '25901', '8125', '2024-12-20 12:49:53', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'رضا', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25901';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:19:54";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:49:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:49:54', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:19:56";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:49:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 12:49:56', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:20:45";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:50:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:50:45', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:20:45";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:50:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:50:45', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067654b84761df
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:48:36', '067654b84761df', '1', '0.00', '0', '0', '1', '670.00', '670', '670', '0', '1', '2024-12-20 12:50:45', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','670','0','','0','0','670','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150345', '0', '2024-12-20 12:50:45', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '670', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 12:48:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 30888;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('445','06101', '150345', '5', '13777', '2', '335', '670', '0', '', '1', '2024-12-20 12:50:45', '13777', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30888-2,','1','1','0','0','335','670','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 445.00 , meanbuyprice = 445.00, lastbuyprice_withDiscount = 445.00, meanbuyprice_withDiscount = 445.00
        
                where sellbilldetailid = 549257;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13777, '2024-12-20', 670, 890, 890
                    , 890, 890, 890, 890
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+670, sellCostBuyPrice =sellCostBuyPrice+890
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+890, sellCostMeanBuyPrice = sellCostMeanBuyPrice+890
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+890, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+890
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+890
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 670, 890, 890
                    , 890, 890, 890, 890
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+670, sellCostBuyPrice =sellCostBuyPrice+890
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+890, sellCostMeanBuyPrice = sellCostMeanBuyPrice+890
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+890, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+890
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+890
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-20 12:50:46' WHERE storedetailid = '13776';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13777', '1', '2', '1', '150345', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '5', '104', '2024-12-20 12:50:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '8795',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8125','670', '0', '1', 'اضافة فاتورة مبيعات', '150345', '8795', '2024-12-20 12:50:46', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 670, 890, 890
                    , 890, 890, 890, 890
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+670, sellCostBuyPrice =sellCostBuyPrice+890
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+890, sellCostMeanBuyPrice = sellCostMeanBuyPrice+890
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+890, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+890
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+890
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 670, 890, 890
                    , 890, 890, 890, 890
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+670, sellCostBuyPrice =sellCostBuyPrice+890
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+890, sellCostMeanBuyPrice = sellCostMeanBuyPrice+890
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+890, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+890
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+890
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 670, 890, 890
                    , 890, 890, 890, 890, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+670, netSellCostBuyPrice = netSellCostBuyPrice+890
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+890
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+890
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+890
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+890
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+890
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067654b84761df and sellbillId = 150345 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:20:46";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 12:50:46", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:50:46', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150341');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:20:47";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:50:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:50:47', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:21:12";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:51:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:51:12', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067654c053e856
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:50:45', '067654c053e856', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2024-12-20 12:51:13', '', '104', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150346', '0', '2024-12-20 12:51:13', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 12:50:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36368;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('150','07296', '150346', '5', '16435', '1', '200', '200', '0', '', '1', '2024-12-20 12:51:13', '16435', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36368-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        , lastbuyprice_withTax = 150, meanbuyprice_withTax = 150, lastbuyprice_withDiscountAndTax = 150
                where sellbilldetailid = 549258;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16435, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '104', storedetaildate = '2024-12-20 12:51:13' WHERE storedetailid = '16434';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16435', '1', '1', '1', '150346', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-20 12:51:13','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '8995',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8795','200', '0', '1', 'اضافة فاتورة مبيعات', '150346', '8995', '2024-12-20 12:51:13', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 24 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 200, 150, 150
                    , 150, 150, 150, 150, 150, 150)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+150
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+150
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+150
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+150
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+150
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+150
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+150
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+150;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067654c053e856 and sellbillId = 150346 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:21:13";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:51:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:51:13', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:21:59";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 12:51:59", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:51:59', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:22:10";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:52:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 12:52:10', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:23:15";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 12:53:15", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:53:15', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:23:59";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:53:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:53:59', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:24:07";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 12:54:07", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:54:07', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150344');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:24:23";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 12:54:23", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:54:23', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150342');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:24:29";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:54:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:54:29', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067654cc788fbc
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:53:59', '067654cc788fbc', '1', '0.00', '0', '0', '1', '400.00', '400', '400', '0', '1', '2024-12-20 12:54:29', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','400','0','','0','0','400','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150347', '0', '2024-12-20 12:54:29', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 12:53:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36469;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('335','07221', '150347', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-20 12:54:29', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36469-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 549259;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16279, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '61', userid = '104', storedetaildate = '2024-12-20 12:54:29' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150347', 'اضافة فاتورة مبيعات', 'sellbillController.php', '62', '61', '104', '2024-12-20 12:54:29','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '9395',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8995','400', '0', '1', 'اضافة فاتورة مبيعات', '150347', '9395', '2024-12-20 12:54:29', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 400, 335, 335
                    , 335, 335, 335, 335, 335, 323)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+400, netSellCostBuyPrice = netSellCostBuyPrice+335
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+335
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+335
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+335
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+335
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+335
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+335
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+323;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067654cc788fbc and sellbillId = 150347 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:24:30";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 12:54:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 12:54:30', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:33:08";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:03:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:03:08', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067654ce68ffee
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:54:30', '067654ce68ffee', '1', '0.00', '0', '0', '1', '760.00', '760', '760', '0', '1', '2024-12-20 13:03:08', '', '104', '0', 'نقدي', '1', '0', '3', '54', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','760','0','','0','0','760','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150348', '0', '2024-12-20 13:03:08', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '760', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 12:54:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35676;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('670','H1335', '150348', '14', '15405', '1', '760', '760', '0', '', '1', '2024-12-20 13:03:08', '15405', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35676-1,','1','1','0','0','760','760','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 735.00 , meanbuyprice = 704.00, lastbuyprice_withDiscount = 735.00, meanbuyprice_withDiscount = 704.00
        , lastbuyprice_withTax = 735, meanbuyprice_withTax = 599, lastbuyprice_withDiscountAndTax = 735
                where sellbilldetailid = 549260;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15405, '2024-12-20', 760, 735, 735
                    , 704, 735, 704, 690.83
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 735, 599, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+760, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+704
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+704
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+690.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+599
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 760, 735, 735
                    , 704, 735, 704, 690.83
                    , 0, 0, 0, 0
                    , 0, 0, 0, 735, 599, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+760, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+704
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+704
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+690.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+599
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '104', storedetaildate = '2024-12-20 13:03:08' WHERE storedetailid = '15404';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15405', '1', '1', '1', '150348', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '104', '2024-12-20 13:03:08','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '10155',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('9395','760', '0', '1', 'اضافة فاتورة مبيعات', '150348', '10155', '2024-12-20 13:03:08', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 54 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 760, 735, 735
                    , 704, 735, 704, 690.83
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,735, 599, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+760, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+704
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+704
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+690.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+599
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 760, 735, 735
                    , 704, 735, 704, 690.83
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,735, 599, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+760, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+704
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+704
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+690.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+599
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 760, 735, 735
                    , 704, 735, 704, 690.83, 735, 599)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+760, netSellCostBuyPrice = netSellCostBuyPrice+735
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+735
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+704
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+735
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+704
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+690.83
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+735
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+599;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067654ce68ffee and sellbillId = 150348 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:33:09";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:03:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:03:09', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:33:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:03:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 13:03:46', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:34:00";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:04:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 13:04:00', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'عبد الرحمن', '', '100', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '10055',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('10155.00','100', '1', '1', 'إضافة مصروف', '25902', '10055', '2024-12-20 13:04:00', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'عبد الرحمن', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25902';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:34:01";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:04:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 13:04:01', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:34:03";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:04:03", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 13:04:03', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:36:26";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:06:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:06:26', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:39:20";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:09:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 13:09:20', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:39:26";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:09:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 13:09:26', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'نفحة', '', '50', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '10005',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('10055.00','50', '1', '1', 'إضافة مصروف', '25903', '10005', '2024-12-20 13:09:26', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'نفحة', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25903';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:39:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:09:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 13:09:27', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:39:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:09:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 13:09:28', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:39:34";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:09:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:09:34', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067654fb257eb3
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 13:06:26', '067654fb257eb3', '1', '0.00', '0', '0', '1', '1330.00', '1330', '1330', '0', '1', '2024-12-20 13:09:34', '', '104', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '5' ,'0','','','','','-1','0','0','0','0','0','1330','0','','0','0','1330','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150349', '0', '2024-12-20 13:09:34', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1330', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 13:06:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36387;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','H1669', '150349', '14', '16450', '1', '270', '270', '0', '', '1', '2024-12-20 13:09:34', '16450', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36387-1,','1','1','0','0','270','270','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 549261;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16450, '2024-12-20', 270, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 270, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '16', userid = '104', storedetaildate = '2024-12-20 13:09:34' WHERE storedetailid = '16449';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16450', '1', '1', '1', '150349', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '104', '2024-12-20 13:09:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36386;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','H1668', '150349', '14', '16449', '1', '280', '280', '0', '', '1', '2024-12-20 13:09:34', '16449', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36386-1,','1','1','0','0','280','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 549262;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16449, '2024-12-20', 280, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 280, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '17', userid = '104', storedetaildate = '2024-12-20 13:09:34' WHERE storedetailid = '16448';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16449', '1', '1', '1', '150349', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '104', '2024-12-20 13:09:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36365;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','07293', '150349', '5', '16434', '1', '200', '200', '0', '', '1', '2024-12-20 13:09:34', '16434', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36365-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549263;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16434, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '104', storedetaildate = '2024-12-20 13:09:34' WHERE storedetailid = '16433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16434', '1', '1', '1', '150349', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '104', '2024-12-20 13:09:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36358;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06603', '150349', '5', '15038', '2', '290', '580', '0', '', '1', '2024-12-20 13:09:34', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36358-2,','1','1','0','0','290','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 226.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 226.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 227, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549264;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15038, '2024-12-20', 580, 450, 450
                    , 452, 450, 452, 471.9
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 450, 454, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+452
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+452
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+471.9
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+454
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 580, 450, 450
                    , 452, 450, 452, 471.9
                    , 0, 0, 0, 0
                    , 0, 0, 0, 450, 454, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+452
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+452
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+471.9
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+454
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '49', userid = '104', storedetaildate = '2024-12-20 13:09:34' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '2', '1', '150349', 'اضافة فاتورة مبيعات', 'sellbillController.php', '51', '49', '104', '2024-12-20 13:09:34','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '11335',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('10005','1330', '0', '1', 'اضافة فاتورة مبيعات', '150349', '11335', '2024-12-20 13:09:34', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 24 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1330, 995, 995
                    , 997, 995, 997, 1016.9
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,995, 999, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1330, sellCostBuyPrice =sellCostBuyPrice+995
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+995, sellCostMeanBuyPrice = sellCostMeanBuyPrice+997
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+995, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+997
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1016.9
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+995
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+999
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1330, 995, 995
                    , 997, 995, 997, 1016.9
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,995, 999, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1330, sellCostBuyPrice =sellCostBuyPrice+995
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+995, sellCostMeanBuyPrice = sellCostMeanBuyPrice+997
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+995, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+997
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1016.9
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+995
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+999
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1330, 995, 995
                    , 997, 995, 997, 1016.9, 995, 999)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1330, netSellCostBuyPrice = netSellCostBuyPrice+995
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+995
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+997
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+995
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+997
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1016.9
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+995
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+999;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067654fb257eb3 and sellbillId = 150349 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:39:35";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:09:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:09:35', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:39:51";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:09:51", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:09:51', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067653172d68d6
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8344,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 10:57:22', '067653172d68d6', '8344', '-2.00', '745', '0', '1', '747.00', '747', '0', '747', '1', '2024-12-20 13:09:51', '', '75', '0', 'ايمان الغردقة I1115', '2', '1', '3', '87', 'ايمان الغردقة I1115', '4' ,'0','','','','','-1','0','0','0','0','0','747','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '745', userid = '75' WHERE clientid = '8344';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8344','-2.00','747','0','اضافة فاتورة مبيعات','150350', '745', '2024-12-20 13:09:51', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '747', '0', null, '0', null, null,'', '0','1','1','747','1','2024-12-20 10:57:22','0','0');
UPDATE client SET  inUse = 0 where clientid = 8344;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35842;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','06872', '150350', '5', '15654', '2', '360', '720', '0', '', '1', '2024-12-20 13:09:52', '15654', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35842-2,','1','1','0','0','360','720','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 356.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 356.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 356, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 549265;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15654, '2024-12-20', 720, 590, 590
                    , 712, 590, 712, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 590, 712, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+712
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+712
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+590
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+590
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+712
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 720, 590, 590
                    , 712, 590, 712, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0, 590, 712, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+712
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+712
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+590
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+590
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+712
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '75', storedetaildate = '2024-12-20 13:09:52' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '2', '1', '150350', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '5', '75', '2024-12-20 13:09:52','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150350', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 13:09:52', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150350', '17', '10291', '1', '7', '7', '0', '', '1', '2024-12-20 13:09:52', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','7','7','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 87 where clientid = 8344;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 747, 590, 590
                    , 712, 590, 712, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,590, 712, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+747, sellCostBuyPrice =sellCostBuyPrice+590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+712
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+712
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+590
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+590
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+712
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8344, '2024-12-20', 747, 590, 590
                    , 712, 590, 712, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,590, 712, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+747, sellCostBuyPrice =sellCostBuyPrice+590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+712
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+712
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+590
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+590
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+712
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 747, 590, 590
                    , 712, 590, 712, 590, 590, 712)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+747, netSellCostBuyPrice = netSellCostBuyPrice+590
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+590
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+712
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+590
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+712
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+590
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+590
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+712;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067653172d68d6 and sellbillId = 150350 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:39:52";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:09:52", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:09:52', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:40:55";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:10:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 13:10:55', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:44:52";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:14:52", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:14:52', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067655080bc49d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7068,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 13:09:52', '067655080bc49d', '7068', '829.00', '1122', '0', '1', '293.00', '293', '0', '293', '1', '2024-12-20 13:14:52', '', '75', '0', 'ام تمارا x40', '2', '1', '3', '85', 'ام تمارا x40', '2' ,'0','','','','','-1','0','0','0','0','0','293','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1122', userid = '75' WHERE clientid = '7068';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7068','829.00','293','0','اضافة فاتورة مبيعات','150351', '1122', '2024-12-20 13:14:52', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '293', '0', null, '0', null, null,'', '0','1','1','293','1','2024-12-20 13:09:52','0','0');
UPDATE client SET  inUse = 0 where clientid = 7068;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36550;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('230','H1654', '150351', '14', '16409', '1', '290', '290', '0', '', '1', '2024-12-20 13:14:52', '16409', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36550-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where sellbilldetailid = 549268;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16409, '2024-12-20', 290, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '75', storedetaildate = '2024-12-20 13:14:52' WHERE storedetailid = '16408';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16409', '1', '1', '1', '150351', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-20 13:14:52','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150351', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-20 13:14:52', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','3','3','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 85 where clientid = 7068;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 293, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+293, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7068, '2024-12-20', 293, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+293, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 293, 230, 230
                    , 230, 230, 230, 230, 230, 230)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+293, netSellCostBuyPrice = netSellCostBuyPrice+230
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+230
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+230
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+230
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+230
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+230
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+230
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+230;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067655080bc49d and sellbillId = 150351 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:44:53";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:14:53", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:14:53', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:49:09";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 13:19:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 13:19:09', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247838
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1104,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-739' , clientdate = '2024-12-20 13:19:09', userid = '2' WHERE clientid = '1104';
UPDATE client SET  inUse = 0 where clientid = 1104;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1104','6987.00','7726','1','ايصال تحصيل (( قبض من عميل ))','247838', '-739', '2024-12-20 12:43:03', '2', 'clientPayedDeptController.php', '   ', '7726', '0', null, '0', null, null,'', '-1','1','1','7726','1','','3620','0');
UPDATE save SET  savecurrentvalue = '87388.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('79662.50','7726', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247848', '87388.5', '2024-12-20 13:19:09', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '7726', '7726', '2024-12-20', '2', '0', '0', '2024-12-20 13:19:09','اضافة ايصال سداد للعميل خالد توينز K3','1','0','0','0','247848','clientPayedDeptController.php?do=show&id=247848');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122279', '-1', '7726', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '7726', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122279', '-1', '7726', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-7726', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '1104', clientdebtchangebefore = '6987.000', clientdebtchangeamount = '7726.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247838', clientdebtchangeafter = '-739.000', clientdebtchangedate = '2024-12-20 12:43:03', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '7726.00',discount='', reciptid='0', dailyentryid = '122279',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='7726',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247848';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247838 -clientdebtchangeId = 247848
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:49:10";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 13:19:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 13:19:10', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:49:30";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 13:19:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:19:30', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:49:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 13:19:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:19:38', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:50:04";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 13:20:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:20:04', '2', 'editsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150341');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:50:44";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 13:20:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:20:44', '2', 'update', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 150341 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 150341 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150341;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 13:20:44', userid = '101',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '150341';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35423;
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549228;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15856, '2024-12-20', 189.22386144965, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-189.22386144965, sellCostBuyPrice =sellCostBuyPrice-140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-140, sellCostMeanBuyPrice = sellCostMeanBuyPrice-140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-140
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 189.22386144965, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-189.22386144965, sellCostBuyPrice =sellCostBuyPrice-140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-140, sellCostMeanBuyPrice = sellCostMeanBuyPrice-140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-140
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '21', userid = '2', storedetaildate = '2024-12-20 13:20:44' WHERE storedetailid = '15855';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15856', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '20', '21', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36351;
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
        , lastbuyprice_withTax = 220, meanbuyprice_withTax = 220, lastbuyprice_withDiscountAndTax = 220
                where sellbilldetailid = 549229;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15853, '2024-12-20', 264.91340602951, 220, 220
                    , 220, 220, 220, 220.79
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-264.91340602951, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-220
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-220
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 264.91340602951, 220, 220
                    , 220, 220, 220, 220.79
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-264.91340602951, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-220
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-220
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '18', userid = '2', storedetaildate = '2024-12-20 13:20:44' WHERE storedetailid = '15852';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15853', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '17', '18', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36349;
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 185.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 185.00
        , lastbuyprice_withTax = 185, meanbuyprice_withTax = 185, lastbuyprice_withDiscountAndTax = 185
                where sellbilldetailid = 549230;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16298, '2024-12-20', 236.52982681206, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 185, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-236.52982681206, sellCostBuyPrice =sellCostBuyPrice-185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-185, sellCostMeanBuyPrice = sellCostMeanBuyPrice-185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-185
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-185
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 236.52982681206, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0, 185, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-236.52982681206, sellCostBuyPrice =sellCostBuyPrice-185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-185, sellCostMeanBuyPrice = sellCostMeanBuyPrice-185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-185
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-185
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '26', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16298', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '25', '26', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36459;
UPDATE sellbilldetail SET  lastbuyprice = 525.00 , meanbuyprice = 525.00, lastbuyprice_withDiscount = 525.00, meanbuyprice_withDiscount = 525.00
        , lastbuyprice_withTax = 525, meanbuyprice_withTax = 525, lastbuyprice_withDiscountAndTax = 525
                where sellbilldetailid = 549231;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16470, '2024-12-20', 614.97754971135, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-614.97754971135, sellCostBuyPrice =sellCostBuyPrice-525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-525, sellCostMeanBuyPrice = sellCostMeanBuyPrice-525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-525
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 614.97754971135, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-614.97754971135, sellCostBuyPrice =sellCostBuyPrice-525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-525, sellCostMeanBuyPrice = sellCostMeanBuyPrice-525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-525
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '3', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16469';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16470', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '2', '3', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 36348;
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549232;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16430, '2024-12-20', 946.11930724824, 800, 800
                    , 800, 800, 800, 800
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 800, 800, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-946.11930724824, sellCostBuyPrice =sellCostBuyPrice-800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-800, sellCostMeanBuyPrice = sellCostMeanBuyPrice-800
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-800
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-800
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-800
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-800
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-2
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 946.11930724824, 800, 800
                    , 800, 800, 800, 800
                    , 0, 0, 0, 0
                    , 0, 0, 0, 800, 800, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-946.11930724824, sellCostBuyPrice =sellCostBuyPrice-800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-800, sellCostMeanBuyPrice = sellCostMeanBuyPrice-800
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-800
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-800
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-800
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-800
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '16', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16429';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16430', '1', '2', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '14', '16', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36098;
UPDATE sellbilldetail SET  lastbuyprice = 570.00 , meanbuyprice = 569.00, lastbuyprice_withDiscount = 570.00, meanbuyprice_withDiscount = 569.00
        , lastbuyprice_withTax = 570, meanbuyprice_withTax = 568, lastbuyprice_withDiscountAndTax = 570
                where sellbilldetailid = 549233;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16318, '2024-12-20', 614.97754971135, 570, 570
                    , 569, 570, 569, 570
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 570, 568, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-614.97754971135, sellCostBuyPrice =sellCostBuyPrice-570
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-570, sellCostMeanBuyPrice = sellCostMeanBuyPrice-569
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-570, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-569
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-570
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-570
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-568
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 614.97754971135, 570, 570
                    , 569, 570, 569, 570
                    , 0, 0, 0, 0
                    , 0, 0, 0, 570, 568, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-614.97754971135, sellCostBuyPrice =sellCostBuyPrice-570
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-570, sellCostMeanBuyPrice = sellCostMeanBuyPrice-569
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-570, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-569
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-570
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-570
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-568
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '14', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16317';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16318', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '13', '14', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36417;
UPDATE sellbilldetail SET  lastbuyprice = 630.00 , meanbuyprice = 630.00, lastbuyprice_withDiscount = 630.00, meanbuyprice_withDiscount = 630.00
        , lastbuyprice_withTax = 630, meanbuyprice_withTax = 630, lastbuyprice_withDiscountAndTax = 630
                where sellbilldetailid = 549234;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16455, '2024-12-20', 690.66709429121, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-690.66709429121, sellCostBuyPrice =sellCostBuyPrice-630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-630, sellCostMeanBuyPrice = sellCostMeanBuyPrice-630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-630
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 690.66709429121, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-690.66709429121, sellCostBuyPrice =sellCostBuyPrice-630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-630, sellCostMeanBuyPrice = sellCostMeanBuyPrice-630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-630
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '12', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16454';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16455', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '11', '12', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35830;
UPDATE sellbilldetail SET  lastbuyprice = 440.00 , meanbuyprice = 440.00, lastbuyprice_withDiscount = 440.00, meanbuyprice_withDiscount = 440.00
        , lastbuyprice_withTax = 440, meanbuyprice_withTax = 440, lastbuyprice_withDiscountAndTax = 440
                where sellbilldetailid = 549235;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16244, '2024-12-20', 454.13726747915, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-454.13726747915, sellCostBuyPrice =sellCostBuyPrice-440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-440, sellCostMeanBuyPrice = sellCostMeanBuyPrice-440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-440
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 454.13726747915, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-454.13726747915, sellCostBuyPrice =sellCostBuyPrice-440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-440, sellCostMeanBuyPrice = sellCostMeanBuyPrice-440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-440
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '7', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16243';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16244', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '6', '7', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 36142;
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 151.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 151.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 153, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549236;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16294, '2024-12-20', 397.37010904426, 310, 310
                    , 302, 310, 302, 306.24
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 310, 306, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-397.37010904426, sellCostBuyPrice =sellCostBuyPrice-310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-310, sellCostMeanBuyPrice = sellCostMeanBuyPrice-302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-306.24
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-306
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-2
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 397.37010904426, 310, 310
                    , 302, 310, 302, 306.24
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 306, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-397.37010904426, sellCostBuyPrice =sellCostBuyPrice-310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-310, sellCostMeanBuyPrice = sellCostMeanBuyPrice-302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-306.24
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-306
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '73', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '2', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '71', '73', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 36109;
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 160, lastbuyprice_withDiscountAndTax = 160
                where sellbilldetailid = 549237;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16378, '2024-12-20', 416.29249518922, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-416.29249518922, sellCostBuyPrice =sellCostBuyPrice-320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-320, sellCostMeanBuyPrice = sellCostMeanBuyPrice-320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-320
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-320
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-2
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 416.29249518922, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-416.29249518922, sellCostBuyPrice =sellCostBuyPrice-320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-320, sellCostMeanBuyPrice = sellCostMeanBuyPrice-320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-320
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-320
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '9', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16377';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16378', '1', '2', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '7', '9', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36315;
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549238;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16415, '2024-12-20', 189.22386144965, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-189.22386144965, sellCostBuyPrice =sellCostBuyPrice-140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-140, sellCostMeanBuyPrice = sellCostMeanBuyPrice-140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-140
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 189.22386144965, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-189.22386144965, sellCostBuyPrice =sellCostBuyPrice-140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-140, sellCostMeanBuyPrice = sellCostMeanBuyPrice-140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-140
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '19', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16414';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16415', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '18', '19', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35992;
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where sellbilldetailid = 549239;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16337, '2024-12-20', 264.91340602951, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-264.91340602951, sellCostBuyPrice =sellCostBuyPrice-230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-230, sellCostMeanBuyPrice = sellCostMeanBuyPrice-230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-230
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 264.91340602951, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-264.91340602951, sellCostBuyPrice =sellCostBuyPrice-230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-230, sellCostMeanBuyPrice = sellCostMeanBuyPrice-230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-230
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '33', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16336';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16337', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '32', '33', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 33646;
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
        
                where sellbilldetailid = 549240;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15192, '2024-12-20', 340.60295060936, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-340.60295060936, sellCostBuyPrice =sellCostBuyPrice-320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-320, sellCostMeanBuyPrice = sellCostMeanBuyPrice-320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 340.60295060936, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-340.60295060936, sellCostBuyPrice =sellCostBuyPrice-320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-320, sellCostMeanBuyPrice = sellCostMeanBuyPrice-320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '6', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '15191';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15192', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '5', '6', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35821;
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 235.00
        , lastbuyprice_withTax = 235, meanbuyprice_withTax = 235, lastbuyprice_withDiscountAndTax = 235
                where sellbilldetailid = 549241;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16091, '2024-12-20', 269.64400256575, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-269.64400256575, sellCostBuyPrice =sellCostBuyPrice-235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-235, sellCostMeanBuyPrice = sellCostMeanBuyPrice-235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-235
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 269.64400256575, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-269.64400256575, sellCostBuyPrice =sellCostBuyPrice-235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-235, sellCostMeanBuyPrice = sellCostMeanBuyPrice-235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-235
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '21', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16090';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16091', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '20', '21', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36355;
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 295.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 295.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 549242;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15967, '2024-12-20', 340.60295060936, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-340.60295060936, sellCostBuyPrice =sellCostBuyPrice-295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-295, sellCostMeanBuyPrice = sellCostMeanBuyPrice-295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-295
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 340.60295060936, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-340.60295060936, sellCostBuyPrice =sellCostBuyPrice-295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-295, sellCostMeanBuyPrice = sellCostMeanBuyPrice-295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-295
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '35', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '15966';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15967', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '34', '35', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36128;
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 70, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549243;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16385, '2024-12-20', 189.22386144965, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 140, 70, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-189.22386144965, sellCostBuyPrice =sellCostBuyPrice-140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-140, sellCostMeanBuyPrice = sellCostMeanBuyPrice-140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-70
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 189.22386144965, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 70, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-189.22386144965, sellCostBuyPrice =sellCostBuyPrice-140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-140, sellCostMeanBuyPrice = sellCostMeanBuyPrice-140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-70
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '8', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16384';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16385', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '7', '8', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36003;
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549244;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16293, '2024-12-20', 189.22386144965, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-189.22386144965, sellCostBuyPrice =sellCostBuyPrice-155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-155, sellCostMeanBuyPrice = sellCostMeanBuyPrice-155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-155
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 189.22386144965, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-189.22386144965, sellCostBuyPrice =sellCostBuyPrice-155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-155, sellCostMeanBuyPrice = sellCostMeanBuyPrice-155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-155
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '35', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '34', '35', '2', '2024-12-20 12:11:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36399;
UPDATE sellbilldetail SET  lastbuyprice = 735.00 , meanbuyprice = 737.00, lastbuyprice_withDiscount = 735.00, meanbuyprice_withDiscount = 737.00
        , lastbuyprice_withTax = 735, meanbuyprice_withTax = 739, lastbuyprice_withDiscountAndTax = 735
                where sellbilldetailid = 549245;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16454, '2024-12-20', 766.35663887107, 735, 735
                    , 737, 735, 737, 740
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 735, 739, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-766.35663887107, sellCostBuyPrice =sellCostBuyPrice-735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-735, sellCostMeanBuyPrice = sellCostMeanBuyPrice-737
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-737
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-740
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-739
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 766.35663887107, 735, 735
                    , 737, 735, 737, 740
                    , 0, 0, 0, 0
                    , 0, 0, 0, 735, 739, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-766.35663887107, sellCostBuyPrice =sellCostBuyPrice-735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-735, sellCostMeanBuyPrice = sellCostMeanBuyPrice-737
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-737
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-740
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-739
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '23', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16453';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16454', '1', '1', '0', '150341', 'تعديل فاتورة مبيعات', 'sellbillController.php', '22', '23', '2', '2024-12-20 12:11:38','0','0');
CALL clientInUse(1104,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-8114', userid = '2' WHERE clientid = '1104';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1104','-739.00','7375.00','1','تعديل فاتورة مبيعات','150341', '-8114', '2024-12-20 12:11:38', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '7375', '0', null, '0', null, null,'', '0','1','1','7375','1','2024-12-20 12:11:38','0','0');
UPDATE client SET  inUse = 0 where clientid = 1104;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 7375, 6390, 6390
                    , 6383, 6390, 6383, 6392.03
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6070, 5998, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-7375, sellCostBuyPrice =sellCostBuyPrice-6390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-6390, sellCostMeanBuyPrice = sellCostMeanBuyPrice-6383
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-6390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-6383
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-6392.03
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-6070
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-5998
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1104, '2024-12-20', 7375, 6390, 6390
                    , 6383, 6390, 6383, 6392.03
                    , 0, 0, 0, 0
                    , 0, 0, 0, 6070, 5998, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-7375, sellCostBuyPrice =sellCostBuyPrice-6390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-6390, sellCostMeanBuyPrice = sellCostMeanBuyPrice-6383
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-6390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-6383
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-6392.03
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-6070
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-5998
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 7375, 6390, 6390
                    , 6383, 6390, 6383, 6392.03, 6070, 5998)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-7375, netSellCostBuyPrice = netSellCostBuyPrice-6390
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-6390
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-6383
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-6390
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-6383
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-6392.03
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-6070
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-5998;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 150341 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 150341 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(1104,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:11:38', '0676542dad96b8', '1104', '-8114.00', '-1024', '420', '1', '7510', '7090', '0', '7090', '1', '2024-12-20 12:11:38', '', '2', '0', 'خالد توينز K3', '2', '1', '3', '79', 'خالد توينز K3', '21', '150341', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '-1024', userid = '2' WHERE clientid = '1104';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1104','-8114.00','7090','0','اضافة فاتورة مبيعات (معدله)','150352', '-1024', '2024-12-20 13:20:45', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '7090', '0', null, '0', null, null,'', '0','1','1','7375','1','2024-12-20 12:11:38','0','0');
UPDATE client SET  inUse = 0 where clientid = 1104;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35423;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','06959', '150352', '5', '15856', '1', '200', '200', '0', '', '1', '2024-12-20 13:20:45', '15856', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35423-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549270;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15856, '2024-12-20', 188.81491344874, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+188.81491344874, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 188.81491344874, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+188.81491344874, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '15855';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15856', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '21', '20', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36351;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('220','H1464', '150352', '14', '15853', '1', '280', '280', '0', '', '1', '2024-12-20 13:20:45', '15853', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36351-1,','1','1','0','0','280','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
        , lastbuyprice_withTax = 220, meanbuyprice_withTax = 220, lastbuyprice_withDiscountAndTax = 220
                where sellbilldetailid = 549271;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15853, '2024-12-20', 264.34087882823, 220, 220
                    , 220, 220, 220, 220.79
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+264.34087882823, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+220
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+220
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 264.34087882823, 220, 220
                    , 220, 220, 220, 220.79
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+264.34087882823, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+220
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+220
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '17', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '15852';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15853', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '18', '17', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36349;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('185','H1619', '150352', '14', '16298', '1', '250', '250', '0', '', '1', '2024-12-20 13:20:45', '16298', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36349-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 185.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 185.00
        , lastbuyprice_withTax = 185, meanbuyprice_withTax = 185, lastbuyprice_withDiscountAndTax = 185
                where sellbilldetailid = 549272;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16298, '2024-12-20', 236.01864181092, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 185, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+236.01864181092, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+185
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+185
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 236.01864181092, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0, 185, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+236.01864181092, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+185
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+185
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '25', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16298', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '26', '25', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36459;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('525','H1666', '150352', '14', '16470', '1', '650', '650', '0', '', '1', '2024-12-20 13:20:45', '16470', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36459-1,','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 525.00 , meanbuyprice = 525.00, lastbuyprice_withDiscount = 525.00, meanbuyprice_withDiscount = 525.00
        , lastbuyprice_withTax = 525, meanbuyprice_withTax = 525, lastbuyprice_withDiscountAndTax = 525
                where sellbilldetailid = 549273;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16470, '2024-12-20', 613.64846870839, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+613.64846870839, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 613.64846870839, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+613.64846870839, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16469';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16470', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '3', '2', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36348;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('400','H1661', '150352', '14', '16430', '2', '500', '1000', '0', '', '1', '2024-12-20 13:20:45', '16430', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36348-2,','1','1','0','0','500','1000','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549274;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16430, '2024-12-20', 944.07456724368, 800, 800
                    , 800, 800, 800, 800
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 800, 800, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+944.07456724368, sellCostBuyPrice =sellCostBuyPrice+800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+800, sellCostMeanBuyPrice = sellCostMeanBuyPrice+800
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+800
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+800
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+800
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+800
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 944.07456724368, 800, 800
                    , 800, 800, 800, 800
                    , 0, 0, 0, 0
                    , 0, 0, 0, 800, 800, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+944.07456724368, sellCostBuyPrice =sellCostBuyPrice+800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+800, sellCostMeanBuyPrice = sellCostMeanBuyPrice+800
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+800
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+800
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+800
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+800
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16429';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16430', '1', '2', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '16', '14', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36098;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('570','H1603', '150352', '14', '16318', '1', '650', '650', '0', '', '1', '2024-12-20 13:20:45', '16318', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36098-1,','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 570.00 , meanbuyprice = 569.00, lastbuyprice_withDiscount = 570.00, meanbuyprice_withDiscount = 569.00
        , lastbuyprice_withTax = 570, meanbuyprice_withTax = 568, lastbuyprice_withDiscountAndTax = 570
                where sellbilldetailid = 549275;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16318, '2024-12-20', 613.64846870839, 570, 570
                    , 569, 570, 569, 570
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 570, 568, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+613.64846870839, sellCostBuyPrice =sellCostBuyPrice+570
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+570, sellCostMeanBuyPrice = sellCostMeanBuyPrice+569
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+570, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+569
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+570
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+570
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+568
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 613.64846870839, 570, 570
                    , 569, 570, 569, 570
                    , 0, 0, 0, 0
                    , 0, 0, 0, 570, 568, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+613.64846870839, sellCostBuyPrice =sellCostBuyPrice+570
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+570, sellCostMeanBuyPrice = sellCostMeanBuyPrice+569
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+570, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+569
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+570
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+570
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+568
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16317';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16318', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '14', '13', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36417;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('630','H1647', '150352', '14', '16455', '1', '730', '730', '0', '', '1', '2024-12-20 13:20:45', '16455', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36417-1,','1','1','0','0','730','730','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 630.00 , meanbuyprice = 630.00, lastbuyprice_withDiscount = 630.00, meanbuyprice_withDiscount = 630.00
        , lastbuyprice_withTax = 630, meanbuyprice_withTax = 630, lastbuyprice_withDiscountAndTax = 630
                where sellbilldetailid = 549276;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16455, '2024-12-20', 689.17443408788, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+689.17443408788, sellCostBuyPrice =sellCostBuyPrice+630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+630
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 689.17443408788, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+689.17443408788, sellCostBuyPrice =sellCostBuyPrice+630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+630
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16454';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16455', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '12', '11', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35830;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('440','07176', '150352', '5', '16244', '1', '480', '480', '0', '', '1', '2024-12-20 13:20:45', '16244', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35830-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 440.00 , meanbuyprice = 440.00, lastbuyprice_withDiscount = 440.00, meanbuyprice_withDiscount = 440.00
        , lastbuyprice_withTax = 440, meanbuyprice_withTax = 440, lastbuyprice_withDiscountAndTax = 440
                where sellbilldetailid = 549277;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16244, '2024-12-20', 453.15579227696, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+453.15579227696, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+440
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 453.15579227696, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+453.15579227696, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+440
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16243';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16244', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '7', '6', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36142;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07226', '150352', '5', '16294', '2', '210', '420', '0', '', '1', '2024-12-20 13:20:45', '16294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36142-2,','1','1','0','0','210','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 151.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 151.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 153, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549278;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16294, '2024-12-20', 396.51131824234, 310, 310
                    , 302, 310, 302, 306.24
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 310, 306, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+396.51131824234, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+306.24
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+306
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 396.51131824234, 310, 310
                    , 302, 310, 302, 306.24
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 306, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+396.51131824234, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+306.24
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+306
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '71', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '2', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '73', '71', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36109;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('160','07269', '150352', '5', '16378', '2', '220', '440', '0', '', '1', '2024-12-20 13:20:45', '16378', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36109-2,','1','1','0','0','220','440','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 160, lastbuyprice_withDiscountAndTax = 160
                where sellbilldetailid = 549279;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16378, '2024-12-20', 415.39280958722, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+415.39280958722, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+320
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+320
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 415.39280958722, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+415.39280958722, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+320
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+320
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16377';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16378', '1', '2', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '9', '7', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36315;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07284', '150352', '5', '16415', '1', '200', '200', '0', '', '1', '2024-12-20 13:20:45', '16415', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36315-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549280;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16415, '2024-12-20', 188.81491344874, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+188.81491344874, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 188.81491344874, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+188.81491344874, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '18', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16414';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16415', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '19', '18', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35992;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('230','07252', '150352', '5', '16337', '1', '280', '280', '0', '', '1', '2024-12-20 13:20:45', '16337', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35992-1,','1','1','0','0','280','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where sellbilldetailid = 549281;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16337, '2024-12-20', 264.34087882823, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+264.34087882823, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 264.34087882823, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+264.34087882823, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '32', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16336';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16337', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '33', '32', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35821;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('235','07085', '150352', '5', '16091', '1', '285', '285', '0', '', '1', '2024-12-20 13:20:45', '16091', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35821-1,','1','1','0','0','285','285','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 235.00
        , lastbuyprice_withTax = 235, meanbuyprice_withTax = 235, lastbuyprice_withDiscountAndTax = 235
                where sellbilldetailid = 549282;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16091, '2024-12-20', 269.06125166445, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+269.06125166445, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+235
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 269.06125166445, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+269.06125166445, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+235
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16090';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16091', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '21', '20', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36355;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','H1522', '150352', '14', '15967', '1', '360', '360', '0', '', '1', '2024-12-20 13:20:45', '15967', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36355-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 295.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 295.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 549283;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15967, '2024-12-20', 339.86684420772, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+339.86684420772, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 339.86684420772, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+339.86684420772, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '34', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '15966';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15967', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '35', '34', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36128;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07264', '150352', '5', '16385', '1', '200', '200', '0', '', '1', '2024-12-20 13:20:45', '16385', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36128-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 70, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549284;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16385, '2024-12-20', 188.81491344874, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 70, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+188.81491344874, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+70
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 188.81491344874, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 70, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+188.81491344874, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+70
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16384';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16385', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '8', '7', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36003;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07220', '150352', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-20 13:20:45', '16293', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36003-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549285;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16293, '2024-12-20', 188.81491344874, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+188.81491344874, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 188.81491344874, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+188.81491344874, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '34', userid = '2', storedetaildate = '2024-12-20 13:20:45' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '35', '34', '2', '2024-12-20 13:20:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36399;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('745','07305', '150352', '5', '16454', '1', '810', '810', '0', '', '1', '2024-12-20 13:20:45', '16454', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36399-1,','1','1','0','0','810','810','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 735.00 , meanbuyprice = 737.00, lastbuyprice_withDiscount = 735.00, meanbuyprice_withDiscount = 737.00
        , lastbuyprice_withTax = 735, meanbuyprice_withTax = 739, lastbuyprice_withDiscountAndTax = 735
                where sellbilldetailid = 549286;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16454, '2024-12-20', 764.70039946738, 735, 735
                    , 737, 735, 737, 740
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 735, 739, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+764.70039946738, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+737
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+737
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+740
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+739
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 764.70039946738, 735, 735
                    , 737, 735, 737, 740
                    , 0, 0, 0, 0
                    , 0, 0, 0, 735, 739, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+764.70039946738, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+737
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+737
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+740
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+739
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '22', userid = '2', storedetaildate = '2024-12-20 13:20:46' WHERE storedetailid = '16453';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16454', '1', '1', '1', '150352', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '23', '22', '2', '2024-12-20 13:20:46','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150352', '17', '10291', '1', '75', '75', '0', '', '1', '2024-12-20 13:20:46', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','75','75','0','','0','0.00','0','0','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 7090, 6070, 6070
                    , 6063, 6070, 6063, 6072.03
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6070, 5998, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7090, sellCostBuyPrice =sellCostBuyPrice+6070
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6070, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6063
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6070, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6063
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6072.03
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+6070
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5998
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1104, '2024-12-20', 7090, 6070, 6070
                    , 6063, 6070, 6063, 6072.03
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6070, 5998, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7090, sellCostBuyPrice =sellCostBuyPrice+6070
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6070, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6063
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6070, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6063
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6072.03
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+6070
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5998
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 7090, 6070, 6070
                    , 6063, 6070, 6063, 6072.03, 6070, 5998)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+7090, netSellCostBuyPrice = netSellCostBuyPrice+6070
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+6070
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+6063
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+6070
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+6063
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+6072.03
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+6070
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+5998;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150341 and newid=150352 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:50:46";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 13:20:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:20:46', '2', 'editprint', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150352');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:51:04";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 13:21:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 13:21:04', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE userid = 75;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:51:30";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:21:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 13:21:30', '2', '', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:51:30";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:51:31";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:21:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 13:21:31', '2', '', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:51:32";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:51:34";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:21:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 13:21:34', '2', '', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:51:42";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:21:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 13:21:42', '2', '', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:51:52";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:21:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 13:21:52', '2', '', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE userid = 2;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:52:18";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:22:18", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 13:22:18', '75', '', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:52:19";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:52:21";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:22:21", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:22:21', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:52:23";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:22:23", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:22:23', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:52:27";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 13:22:27", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:22:27', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:52:47";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 13:22:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 13:22:47', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247849
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8766,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '51' , clientdate = '2024-12-20 13:22:47', userid = '2' WHERE clientid = '8766';
UPDATE client SET  inUse = 0 where clientid = 8766;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8766','1306.00','1255','1','ايصال تحصيل (( قبض من عميل ))','247849', '51', '2024-12-20 13:19:10', '2', 'clientPayedDeptController.php', '   ', '1255', '0', null, '0', null, null,'', '-1','1','1','1255','1','','3621','0');
UPDATE save SET  savecurrentvalue = '88643.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('87388.50','1255', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247851', '88643.5', '2024-12-20 13:22:47', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1255', '1255', '2024-12-20', '2', '0', '0', '2024-12-20 13:22:48','اضافة ايصال سداد للعميل فادية عزت W4','1','0','0','0','247851','clientPayedDeptController.php?do=show&id=247851');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122280', '-1', '1255', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1255', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122280', '-1', '1255', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1255', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '8766', clientdebtchangebefore = '1306.000', clientdebtchangeamount = '1255.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247849', clientdebtchangeafter = '51.000', clientdebtchangedate = '2024-12-20 13:19:10', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1255.00',discount='', reciptid='0', dailyentryid = '122280',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1255',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247851';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247849 -clientdebtchangeId = 247851
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:52:48";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 13:22:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 13:22:48', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:53:14";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:23:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 13:23:14', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:54:02";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:24:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 13:24:02', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'توينز', '', '1000', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '10335',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('11335.00','1000', '1', '1', 'إضافة مصروف', '25904', '10335', '2024-12-20 13:24:02', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'توينز', expensesdetails = '', expensesValue = '1000.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25904';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:54:02";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:24:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 13:24:02', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:54:04";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:24:04", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 13:24:04', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:54:21";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 13:24:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 13:24:21', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247852
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(451,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 13:24:21', userid = '2' WHERE clientid = '451';
UPDATE client SET  inUse = 0 where clientid = 451;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('451','2838.00','2838','1','ايصال تحصيل (( قبض من عميل ))','247852', '0', '2024-12-20 13:22:48', '2', 'clientPayedDeptController.php', '   ', '2838', '0', null, '0', null, null,'', '-1','1','1','2838','1','','3622','0');
UPDATE save SET  savecurrentvalue = '91481.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('88643.50','2838', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247852', '91481.5', '2024-12-20 13:24:21', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '2838', '2838', '2024-12-20', '2', '0', '0', '2024-12-20 13:24:21','اضافة ايصال سداد للعميل دعاء شماتة p86','1','0','0','0','247852','clientPayedDeptController.php?do=show&id=247852');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122281', '-1', '2838', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '2838', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122281', '-1', '2838', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-2838', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '451', clientdebtchangebefore = '2838.000', clientdebtchangeamount = '2838.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247852', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 13:22:48', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '2838.00',discount='', reciptid='0', dailyentryid = '122281',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='2838',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247852';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247852 -clientdebtchangeId = 247852
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:54:22";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 13:24:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 13:24:22', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:54:47";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:24:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:24:47', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:55:45";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:25:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:25:45', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:56:10";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:26:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:26:10', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676554394a481
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 13:25:45', '0676554394a481', '1', '0.00', '0', '0', '1', '460.00', '460', '460', '0', '1', '2024-12-20 13:26:10', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','460','0','','0','0','460','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150353', '0', '2024-12-20 13:26:10', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '460', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 13:25:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35558;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('210','07081', '150353', '5', '16073', '1', '260', '260', '0', '', '1', '2024-12-20 13:26:10', '16073', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35558-1,','1','1','0','0','260','260','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where sellbilldetailid = 549288;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16073, '2024-12-20', 260, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+210
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+210
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 260, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+210
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+210
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-3', userid = '104', storedetaildate = '2024-12-20 13:26:10' WHERE storedetailid = '16072';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16073', '1', '1', '1', '150353', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-2', '-3', '104', '2024-12-20 13:26:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35924;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07208', '150353', '5', '16301', '1', '200', '200', '0', '', '1', '2024-12-20 13:26:10', '16301', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35924-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549289;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16301, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-20 13:26:10' WHERE storedetailid = '16300';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16301', '1', '1', '1', '150353', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-20 13:26:10','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '10795',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('10335','460', '0', '1', 'اضافة فاتورة مبيعات', '150353', '10795', '2024-12-20 13:26:10', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 460, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 460, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 460, 350, 350
                    , 350, 350, 350, 350, 350, 350)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+460, netSellCostBuyPrice = netSellCostBuyPrice+350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+350
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+350
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+350
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+350
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+350
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+350;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676554394a481 and sellbillId = 150353 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:56:11";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:26:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:26:11', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:58:21";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:28:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:28:21', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676553ffc95e0
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 13:24:47', '0676553ffc95e0', '1', '0.00', '0', '0', '1', '1040.00', '1040', '1040', '0', '1', '2024-12-20 13:28:21', '', '104', '0', 'نقدي', '1', '0', '3', '25', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1040','0','','0','0','1040','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150354', '0', '2024-12-20 13:28:21', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1040', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 13:24:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35842;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','06872', '150354', '5', '15654', '1', '360', '360', '0', '', '1', '2024-12-20 13:28:21', '15654', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35842-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 356.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 356.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 356, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 549290;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15654, '2024-12-20', 360, 295, 295
                    , 356, 295, 356, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 356, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+356
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+356
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+356
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 295, 295
                    , 356, 295, 356, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 356, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+356
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+356
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+356
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '104', storedetaildate = '2024-12-20 13:28:21' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '1', '1', '150354', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-20 13:28:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36003;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07220', '150354', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-20 13:28:21', '16293', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36003-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549291;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16293, '2024-12-20', 200, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '33', userid = '104', storedetaildate = '2024-12-20 13:28:21' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '150354', 'اضافة فاتورة مبيعات', 'sellbillController.php', '34', '33', '104', '2024-12-20 13:28:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35873;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('420','07037', '150354', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-20 13:28:21', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35873-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 549292;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15995, '2024-12-20', 480, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 480, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '57', userid = '104', storedetaildate = '2024-12-20 13:28:21' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '150354', 'اضافة فاتورة مبيعات', 'sellbillController.php', '58', '57', '104', '2024-12-20 13:28:21','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '11835',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('10795','1040', '0', '1', 'اضافة فاتورة مبيعات', '150354', '11835', '2024-12-20 13:28:21', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 25 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1040, 870, 870
                    , 931, 870, 931, 870
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,870, 931, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1040, sellCostBuyPrice =sellCostBuyPrice+870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+870, sellCostMeanBuyPrice = sellCostMeanBuyPrice+931
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+931
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+870
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+931
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1040, 870, 870
                    , 931, 870, 931, 870
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,870, 931, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1040, sellCostBuyPrice =sellCostBuyPrice+870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+870, sellCostMeanBuyPrice = sellCostMeanBuyPrice+931
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+931
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+870
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+931
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1040, 870, 870
                    , 931, 870, 931, 870, 870, 931)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1040, netSellCostBuyPrice = netSellCostBuyPrice+870
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+870
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+931
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+870
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+931
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+870
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+870
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+931;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676553ffc95e0 and sellbillId = 150354 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 09:58:22";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:28:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:28:22', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:02:53";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:32:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:32:53', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765545379a41
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3266,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 13:26:11', '06765545379a41', '3266', '0.00', '1798', '0', '1', '1798.00', '1798', '0', '1798', '1', '2024-12-20 13:32:53', '', '104', '0', 'فاطمة ابو ليلة 73', '1', '1', '3', '4', 'فاطمة ابو ليلة 73', '4' ,'0','','','','','-1','0','0','0','0','0','1798','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1798', userid = '104' WHERE clientid = '3266';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3266','0.00','1798','0','اضافة فاتورة مبيعات','150355', '1798', '2024-12-20 13:32:53', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1798', '0', null, '0', null, null,'', '0','1','1','1798','1','2024-12-20 13:26:11','0','0');
UPDATE client SET  inUse = 0 where clientid = 3266;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35969;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('550','R3327', '150355', '1', '16277', '1', '650', '650', '0', '', '1', '2024-12-20 13:32:53', '16277', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35969-1,','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 550.00 , meanbuyprice = 549.00, lastbuyprice_withDiscount = 550.00, meanbuyprice_withDiscount = 547.00
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 548, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 549293;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16277, '2024-12-20', 650, 550, 550
                    , 549, 550, 547, 546.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 550, 548, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+549
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+547
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+546.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+548
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 650, 550, 550
                    , 549, 550, 547, 546.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 548, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+549
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+547
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+546.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+548
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '42', userid = '104', storedetaildate = '2024-12-20 13:32:53' WHERE storedetailid = '16276';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16277', '1', '1', '1', '150355', 'اضافة فاتورة مبيعات', 'sellbillController.php', '43', '42', '104', '2024-12-20 13:32:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36356;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('440','H1623', '150355', '14', '16312', '1', '530', '530', '0', '', '1', '2024-12-20 13:32:53', '16312', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36356-1,','1','1','0','0','530','530','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 440.00 , meanbuyprice = 440.00, lastbuyprice_withDiscount = 440.00, meanbuyprice_withDiscount = 440.00
        , lastbuyprice_withTax = 440, meanbuyprice_withTax = 440, lastbuyprice_withDiscountAndTax = 440
                where sellbilldetailid = 549294;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16312, '2024-12-20', 530, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+440
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 530, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+440
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '17', userid = '104', storedetaildate = '2024-12-20 13:32:53' WHERE storedetailid = '16311';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16312', '1', '1', '1', '150355', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '104', '2024-12-20 13:32:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36148;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('445','H1621', '150355', '14', '16255', '1', '600', '600', '0', '', '1', '2024-12-20 13:32:53', '16255', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36148-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 435.00 , meanbuyprice = 414.00, lastbuyprice_withDiscount = 435.00, meanbuyprice_withDiscount = 414.00
        , lastbuyprice_withTax = 435, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 435
                where sellbilldetailid = 549295;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16255, '2024-12-20', 600, 435, 435
                    , 414, 435, 414, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 435, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+435
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+435, sellCostMeanBuyPrice = sellCostMeanBuyPrice+414
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+435, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+414
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 435, 435
                    , 414, 435, 414, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 435, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+435
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+435, sellCostMeanBuyPrice = sellCostMeanBuyPrice+414
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+435, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+414
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '104', storedetaildate = '2024-12-20 13:32:53' WHERE storedetailid = '16254';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16255', '1', '1', '1', '150355', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-20 13:32:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150355', '17', '10291', '1', '18', '18', '0', '', '1', '2024-12-20 13:32:53', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','18','18','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 4 where clientid = 3266;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1798, 1425, 1425
                    , 1403, 1425, 1401, 1426.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1425, 1468, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1798, sellCostBuyPrice =sellCostBuyPrice+1425
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1403
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1401
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1426.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1425
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1468
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (3266, '2024-12-20', 1798, 1425, 1425
                    , 1403, 1425, 1401, 1426.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1425, 1468, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1798, sellCostBuyPrice =sellCostBuyPrice+1425
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1403
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1401
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1426.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1425
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1468
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1798, 1425, 1425
                    , 1403, 1425, 1401, 1426.67, 1425, 1468)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1798, netSellCostBuyPrice = netSellCostBuyPrice+1425
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1425
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1403
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1425
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1401
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1426.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1425
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1468;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765545379a41 and sellbillId = 150355 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:02:54";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:32:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:32:54', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:04:15";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:34:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:34:15', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676555e63a135
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 13:32:54', '0676555e63a135', '1', '0.00', '0', '0', '1', '450.00', '450', '450', '0', '1', '2024-12-20 13:34:15', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','450','0','','0','0','450','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150356', '0', '2024-12-20 13:34:15', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '450', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 13:32:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35802;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('190','06951', '150356', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-20 13:34:15', '15850', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35802-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 188, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 549297;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15850, '2024-12-20', 240, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 190, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+188
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 240, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+188
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '41', userid = '104', storedetaildate = '2024-12-20 13:34:15' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '150356', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42', '41', '104', '2024-12-20 13:34:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36384;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('150','H1670', '150356', '14', '16448', '1', '210', '210', '0', '', '1', '2024-12-20 13:34:16', '16448', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36384-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        , lastbuyprice_withTax = 150, meanbuyprice_withTax = 150, lastbuyprice_withDiscountAndTax = 150
                where sellbilldetailid = 549298;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16448, '2024-12-20', 210, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '104', storedetaildate = '2024-12-20 13:34:16' WHERE storedetailid = '16447';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16448', '1', '1', '1', '150356', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '104', '2024-12-20 13:34:16','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '12285',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('11835','450', '0', '1', 'اضافة فاتورة مبيعات', '150356', '12285', '2024-12-20 13:34:16', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 450, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,340, 338, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+338
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 450, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,340, 338, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+338
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 450, 340, 340
                    , 340, 340, 340, 340, 340, 338)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+450, netSellCostBuyPrice = netSellCostBuyPrice+340
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+340
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+340
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+340
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+340
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+340
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+340
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+338;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676555e63a135 and sellbillId = 150356 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:04:16";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:34:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:34:16', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:06:00";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:36:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:36:00', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067655638b9d4f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 13:34:16', '067655638b9d4f', '1', '0.00', '0', '0', '1', '700.00', '700', '700', '0', '1', '2024-12-20 13:36:01', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','700','0','','0','0','700','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150357', '0', '2024-12-20 13:36:01', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '700', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 13:34:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36103;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','07260', '150357', '5', '16374', '1', '300', '300', '0', '', '1', '2024-12-20 13:36:01', '16374', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36103-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 231.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 231.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 238, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549299;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16374, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '104', storedetaildate = '2024-12-20 13:36:01' WHERE storedetailid = '16373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16374', '1', '1', '1', '150357', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '104', '2024-12-20 13:36:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36003;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07220', '150357', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-20 13:36:01', '16293', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36003-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549300;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16293, '2024-12-20', 200, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '32', userid = '104', storedetaildate = '2024-12-20 13:36:01' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '150357', 'اضافة فاتورة مبيعات', 'sellbillController.php', '33', '32', '104', '2024-12-20 13:36:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36300;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','06959', '150357', '5', '15856', '1', '200', '200', '0', '', '1', '2024-12-20 13:36:01', '15856', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36300-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549301;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15856, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '19', userid = '104', storedetaildate = '2024-12-20 13:36:01' WHERE storedetailid = '15855';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15856', '1', '1', '1', '150357', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '104', '2024-12-20 13:36:01','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '12985',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('12285','700', '0', '1', 'اضافة فاتورة مبيعات', '150357', '12985', '2024-12-20 13:36:01', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 3 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 700, 520, 520
                    , 526, 520, 526, 532.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,520, 533, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+526
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+526
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+532.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+520
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+533
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 700, 520, 520
                    , 526, 520, 526, 532.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,520, 533, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+526
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+526
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+532.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+520
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+533
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 700, 520, 520
                    , 526, 520, 526, 532.5, 520, 533)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+700, netSellCostBuyPrice = netSellCostBuyPrice+520
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+520
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+526
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+520
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+526
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+532.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+520
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+533;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067655638b9d4f and sellbillId = 150357 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:06:01";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:36:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:36:01', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:10:25";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:40:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 13:40:25', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:11:34";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:41:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 13:41:34', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:11:50";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:41:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:41:50', '104', 'showDetail', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=148735');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:12:53";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:42:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:42:53', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:12:55";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:42:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:42:55', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:14:15";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:44:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:44:15', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765583f53b97
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 13:42:55', '06765583f53b97', '1', '0.00', '0', '0', '1', '720', '720', '-720', '0', '1', '2024-12-20 13:44:15', '', '104', '0', 'نقدي','1', '0', '5', '5', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-720','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16846', '0', '2024-12-20 13:44:15', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '720', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 13:42:55','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('620.00', '16014', '16846', '14', '16014', '1', '720', '720', '0', '', '1', '0', '16014', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','720','720','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 620.00 , meanbuyprice = 620.00, lastbuyprice_withDiscount = 620.00, meanbuyprice_withDiscount = 620.00
        , lastbuyprice_withTax = 620, meanbuyprice_withTax = 620, lastbuyprice_withDiscountAndTax = 620
                where returnsellbilldetailid = 22035;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16014, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 720, 620, 620, 620
                    , 620, 620, 620, 0, 1, 0, 0, 620, 620)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+720, returnSellCostBuyPrice = returnSellCostBuyPrice+620, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+620
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+620, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+620
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+620
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+620
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+620
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+620
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 720, 620, 620, 620
                    , 620, 620, 620, 0, 0, 620, 620)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+720, returnSellCostBuyPrice = returnSellCostBuyPrice+620, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+620
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+620, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+620
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+620
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+620
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+620
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+620;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-20 13:44:15' WHERE storedetailid = '16013';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16014', '1', '1', '0', '16846', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '4', '5', '104', '2024-12-20 13:44:15','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '12265',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('12985','-720', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16846', '12265', '2024-12-20 13:44:15', '104',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 720, 620, 620, 620
                    , 620, 620, 620 ,0, 0, 620, 620)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+720, returnSellCostBuyPrice = returnSellCostBuyPrice+620, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+620
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+620, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+620
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+620
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+620
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+620
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+620;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 720, 620, 620, 620
                    , 620, 620, 620 ,0, 0, 620, 620)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+720, returnSellCostBuyPrice = returnSellCostBuyPrice+620, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+620
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+620, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+620
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+620
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+620
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+620
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+620;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -720, -620, -620
                    , -620, -620, -620, -620, -620, -620)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-720, netSellCostBuyPrice = netSellCostBuyPrice+-620
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-620
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-620
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-620
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-620
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-620
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-620
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-620;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765583f53b97 and sellbillId = 16846 and returnsellbillId = 16846
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:14:16";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:44:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:44:16', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:14:35";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:44:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:44:35', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:15:03";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:45:03", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:45:03', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676558a3f2467
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 13:44:36', '0676558a3f2467', '1', '0.00', '0', '0', '1', '190.00', '190', '190', '0', '1', '2024-12-20 13:45:03', '', '104', '0', 'نقدي', '1', '0', '3', '25', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','190','0','','0','0','190','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150358', '0', '2024-12-20 13:45:03', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '190', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 13:44:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36331;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','06675', '150358', '5', '15165', '1', '190', '190', '0', '', '1', '2024-12-20 13:45:03', '15165', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36331-1,','1','1','0','0','190','190','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549302;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15165, '2024-12-20', 190, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 190, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-10', userid = '104', storedetaildate = '2024-12-20 13:45:03' WHERE storedetailid = '15164';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15165', '1', '1', '1', '150358', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-9', '-10', '104', '2024-12-20 13:45:03','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '12455',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('12265','190', '0', '1', 'اضافة فاتورة مبيعات', '150358', '12455', '2024-12-20 13:45:03', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 25 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 190, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 190, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 190, 140, 140
                    , 140, 140, 140, 140, 140, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+190, netSellCostBuyPrice = netSellCostBuyPrice+140
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+140
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+140
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+140
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+140
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+140
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676558a3f2467 and sellbillId = 150358 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:15:04";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:45:04", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:45:04', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:16:39";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:46:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 13:46:39', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:16:43";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:46:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:46:43', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:23:26";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:53:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:53:26', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:26:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:56:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:56:27', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067655ab65c1d4
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 13:53:26', '067655ab65c1d4', '1', '0.00', '0', '30', '1', '1290.00', '1260', '1260', '0', '1', '2024-12-20 13:56:27', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1260','0','','0','0','1260','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150359', '0', '2024-12-20 13:56:27', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1260', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 13:53:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35873;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('420','07037', '150359', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-20 13:56:27', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35873-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 549303;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15995, '2024-12-20', 468.83720930233, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+468.83720930233, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 468.83720930233, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+468.83720930233, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '56', userid = '104', storedetaildate = '2024-12-20 13:56:27' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '150359', 'اضافة فاتورة مبيعات', 'sellbillController.php', '57', '56', '104', '2024-12-20 13:56:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36469;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('335','07221', '150359', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-20 13:56:27', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36469-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 549304;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16279, '2024-12-20', 390.6976744186, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390.6976744186, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 390.6976744186, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390.6976744186, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '60', userid = '104', storedetaildate = '2024-12-20 13:56:27' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150359', 'اضافة فاتورة مبيعات', 'sellbillController.php', '61', '60', '104', '2024-12-20 13:56:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36100;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('330','H1645', '150359', '14', '16372', '1', '410', '410', '0', '', '1', '2024-12-20 13:56:27', '16372', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36100-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
        , lastbuyprice_withTax = 330, meanbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 330
                where sellbilldetailid = 549305;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16372, '2024-12-20', 400.46511627907, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400.46511627907, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+330
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400.46511627907, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400.46511627907, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+330
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '104', storedetaildate = '2024-12-20 13:56:27' WHERE storedetailid = '16371';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16372', '1', '1', '1', '150359', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-20 13:56:27','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '13715',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('12455','1260', '0', '1', 'اضافة فاتورة مبيعات', '150359', '13715', '2024-12-20 13:56:27', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1260, 1085, 1085
                    , 1085, 1085, 1085, 1085
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1085, 1073, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1260, sellCostBuyPrice =sellCostBuyPrice+1085
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1085, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1085
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1085, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1085
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1085
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1085
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1073
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1260, 1085, 1085
                    , 1085, 1085, 1085, 1085
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1085, 1073, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1260, sellCostBuyPrice =sellCostBuyPrice+1085
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1085, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1085
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1085, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1085
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1085
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1085
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1073
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1260, 1085, 1085
                    , 1085, 1085, 1085, 1085, 1085, 1073)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1260, netSellCostBuyPrice = netSellCostBuyPrice+1085
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1085
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1085
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1085
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1085
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1085
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1085
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1073;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067655ab65c1d4 and sellbillId = 150359 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:26:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:56:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 13:56:28', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:26:58";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:56:58", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 13:56:58', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:27:23";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:57:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 13:57:23', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247861
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10742,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '121' , clientdate = '2024-12-20 13:57:23', userid = '104' WHERE clientid = '10742';
UPDATE client SET  inUse = 0 where clientid = 10742;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10742','126.00','5','1','ايصال تحصيل (( قبض من عميل ))','247861', '121', '2024-12-20 13:56:58', '104', 'clientPayedDeptController.php', '   ', '5', '0', null, '0', null, null,'', '-1','1','1','5','1','','3623','0');
UPDATE save SET  savecurrentvalue = '13720',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('13715.00','5', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '247861', '13720', '2024-12-20 13:57:23', '104',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '5', '5', '2024-12-20', '104', '0', '0', '2024-12-20 13:57:23','اضافة ايصال سداد للعميل روناء اسيوط 99','1','0','-1','0','247861','clientPayedDeptController.php?do=show&id=247861');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122282', '-1', '5', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '5', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122282', '12551', '5', '','0');
UPDATE accountstree SET name = 'روناء اسيوط 99', customName = 'روناء اسيوط 99', customNameEn = 'روناء اسيوط 99', nameEn = 'روناء اسيوط 99', parent = '58', accountNature = '0', theValue = '-515', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-18 15:17:07' WHERE id = '12551';
UPDATE clientdebtchange SET clientid = '10742', clientdebtchangebefore = '126.000', clientdebtchangeamount = '5.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247861', clientdebtchangeafter = '121.000', clientdebtchangedate = '2024-12-20 13:56:58', userid = '104', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '5.00',discount='', reciptid='0', dailyentryid = '122282',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='5',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247861';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247861 -clientdebtchangeId = 247861
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:27:24";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:57:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 13:57:24', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:27:25";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 13:57:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 13:57:25', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:33:04";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:03:04", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:03:04', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:34:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:04:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:04:27', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067655cf8e5097
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:03:04', '067655cf8e5097', '1', '0.00', '0', '0', '1', '1700.00', '1700', '1700', '0', '1', '2024-12-20 14:04:27', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1700','0','','0','0','1700','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150360', '0', '2024-12-20 14:04:27', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1700', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:03:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36157;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('380','R3328', '150360', '1', '16325', '2', '450', '900', '0', '', '1', '2024-12-20 14:04:27', '16325', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36157-2,','1','1','0','0','450','900','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 380.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 380.00
        , lastbuyprice_withTax = 380, meanbuyprice_withTax = 380, lastbuyprice_withDiscountAndTax = 380
                where sellbilldetailid = 549306;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16325, '2024-12-20', 900, 760, 760
                    , 760, 760, 760, 760
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 760, 760, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+760
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+760, sellCostMeanBuyPrice = sellCostMeanBuyPrice+760
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+760, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+760
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+760
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+760
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+760
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 900, 760, 760
                    , 760, 760, 760, 760
                    , 0, 0, 0, 0
                    , 0, 0, 0, 760, 760, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+760
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+760, sellCostMeanBuyPrice = sellCostMeanBuyPrice+760
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+760, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+760
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+760
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+760
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+760
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '28', userid = '104', storedetaildate = '2024-12-20 14:04:27' WHERE storedetailid = '16324';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16325', '1', '2', '1', '150360', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30', '28', '104', '2024-12-20 14:04:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36377;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('675','H1665', '150360', '14', '16444', '1', '800', '800', '0', '', '1', '2024-12-20 14:04:27', '16444', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36377-1,','1','1','0','0','800','800','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 675.00 , meanbuyprice = 675.00, lastbuyprice_withDiscount = 675.00, meanbuyprice_withDiscount = 675.00
        , lastbuyprice_withTax = 675, meanbuyprice_withTax = 675, lastbuyprice_withDiscountAndTax = 675
                where sellbilldetailid = 549307;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16444, '2024-12-20', 800, 675, 675
                    , 675, 675, 675, 675
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 675, 675, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+675
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+675, sellCostMeanBuyPrice = sellCostMeanBuyPrice+675
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+675, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+675
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+675
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+675
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+675
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 800, 675, 675
                    , 675, 675, 675, 675
                    , 0, 0, 0, 0
                    , 0, 0, 0, 675, 675, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+675
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+675, sellCostMeanBuyPrice = sellCostMeanBuyPrice+675
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+675, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+675
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+675
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+675
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+675
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '104', storedetaildate = '2024-12-20 14:04:27' WHERE storedetailid = '16443';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16444', '1', '1', '1', '150360', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '104', '2024-12-20 14:04:27','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '15420',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('13720','1700', '0', '1', 'اضافة فاتورة مبيعات', '150360', '15420', '2024-12-20 14:04:27', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1700, 1435, 1435
                    , 1435, 1435, 1435, 1435
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1435, 1435, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1700, sellCostBuyPrice =sellCostBuyPrice+1435
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1435, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1435
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1435, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1435
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1435
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1435
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1700, 1435, 1435
                    , 1435, 1435, 1435, 1435
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1435, 1435, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1700, sellCostBuyPrice =sellCostBuyPrice+1435
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1435, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1435
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1435, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1435
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1435
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1435
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1700, 1435, 1435
                    , 1435, 1435, 1435, 1435, 1435, 1435)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1700, netSellCostBuyPrice = netSellCostBuyPrice+1435
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1435
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1435
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1435
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1435
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1435
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1435
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1435;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067655cf8e5097 and sellbillId = 150360 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:34:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:04:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:04:28', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:40:29";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:10:29", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:10:29', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067655373dec22
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3976,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 13:22:27', '067655373dec22', '3976', '0.00', '1263', '0', '1', '1263.00', '1263', '0', '1263', '1', '2024-12-20 14:10:29', '', '75', '0', 'رحاب السيد L195', '2', '1', '3', '80', 'رحاب السيد L195', '7' ,'0','','','','','-1','0','0','0','0','0','1263','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1263', userid = '75' WHERE clientid = '3976';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3976','0.00','1263','0','اضافة فاتورة مبيعات','150361', '1263', '2024-12-20 14:10:29', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1263', '0', null, '0', null, null,'', '0','1','1','1263','1','2024-12-20 13:22:27','0','0');
UPDATE client SET  inUse = 0 where clientid = 3976;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36365;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','07293', '150361', '5', '16434', '1', '200', '200', '0', '', '1', '2024-12-20 14:10:29', '16434', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36365-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549308;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16434, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 14:10:29' WHERE storedetailid = '16433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16434', '1', '1', '1', '150361', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 14:10:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35649;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('260','R3304', '150361', '1', '16045', '1', '310', '310', '0', '', '1', '2024-12-20 14:10:29', '16045', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35649-1,','1','1','0','0','310','310','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 260.00
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 260, lastbuyprice_withDiscountAndTax = 260
                where sellbilldetailid = 549309;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16045, '2024-12-20', 310, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 260, 260, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+260
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 310, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 260, 260, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+260
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '75', storedetaildate = '2024-12-20 14:10:29' WHERE storedetailid = '16044';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16045', '1', '1', '1', '150361', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-20 14:10:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33614;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('255','06577', '150361', '5', '14973', '1', '220', '220', '0', '', '1', '2024-12-20 14:10:29', '14973', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33614-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 255.00 , meanbuyprice = 255.00, lastbuyprice_withDiscount = 255.00, meanbuyprice_withDiscount = 255.00
        
                where sellbilldetailid = 549310;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14973, '2024-12-20', 220, 255, 255
                    , 255, 255, 255, 255
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+255, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+255
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 255, 255
                    , 255, 255, 255, 255
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+255, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+255
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 14:10:29' WHERE storedetailid = '14972';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14973', '1', '1', '1', '150361', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 14:10:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36359;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','07260', '150361', '5', '16374', '1', '300', '300', '0', '', '1', '2024-12-20 14:10:29', '16374', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36359-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 231.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 231.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 238, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549311;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16374, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '75', storedetaildate = '2024-12-20 14:10:29' WHERE storedetailid = '16373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16374', '1', '1', '1', '150361', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-20 14:10:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36320;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('165','R3336', '150361', '1', '16417', '1', '200', '200', '0', '', '1', '2024-12-20 14:10:29', '16417', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36320-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549312;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16417, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '16', userid = '75', storedetaildate = '2024-12-20 14:10:29' WHERE storedetailid = '16416';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16417', '1', '1', '1', '150361', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-20 14:10:29','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150361', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:10:29', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150361', '17', '10291', '1', '13', '13', '0', '', '1', '2024-12-20 14:10:29', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','13','13','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 80 where clientid = 3976;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1263, 1050, 1050
                    , 1056, 1050, 1056, 1062.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,795, 808, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1263, sellCostBuyPrice =sellCostBuyPrice+1050
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1050, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1056
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1050, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1056
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1062.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+795
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+808
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (3976, '2024-12-20', 1263, 1050, 1050
                    , 1056, 1050, 1056, 1062.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,795, 808, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1263, sellCostBuyPrice =sellCostBuyPrice+1050
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1050, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1056
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1050, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1056
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1062.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+795
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+808
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1263, 1050, 1050
                    , 1056, 1050, 1056, 1062.5, 795, 808)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1263, netSellCostBuyPrice = netSellCostBuyPrice+1050
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1050
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1056
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1050
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1056
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1062.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+795
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+808;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067655373dec22 and sellbillId = 150361 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:40:30";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:10:30", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:10:30', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:41:40";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:11:40", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:11:40', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067655eb6215dd
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2277,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:10:30', '067655eb6215dd', '2277', '0.00', '323', '0', '1', '323.00', '323', '0', '323', '1', '2024-12-20 14:11:40', '', '75', '0', 'مروة نجاتي المنيا y15', '2', '1', '3', '80', 'مروة نجاتي المنيا y15', '3' ,'0','','','','','-1','0','0','0','0','0','323','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '323', userid = '75' WHERE clientid = '2277';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2277','0.00','323','0','اضافة فاتورة مبيعات','150362', '323', '2024-12-20 14:11:40', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '323', '0', null, '0', null, null,'', '0','1','1','323','1','2024-12-20 14:10:30','0','0');
UPDATE client SET  inUse = 0 where clientid = 2277;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36359;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','07260', '150362', '5', '16374', '1', '300', '300', '0', '', '1', '2024-12-20 14:11:40', '16374', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36359-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 231.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 231.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 238, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549315;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16374, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '75', storedetaildate = '2024-12-20 14:11:40' WHERE storedetailid = '16373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16374', '1', '1', '1', '150362', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-20 14:11:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150362', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:11:40', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150362', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-20 14:11:40', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','3','3','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 80 where clientid = 2277;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 323, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+323, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2277, '2024-12-20', 323, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+323, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 323, 225, 225
                    , 231, 225, 231, 237.5, 225, 238)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+323, netSellCostBuyPrice = netSellCostBuyPrice+225
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+225
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+231
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+225
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+231
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+237.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+225
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+238;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067655eb6215dd and sellbillId = 150362 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:41:41";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:11:41", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:11:41', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:42:53";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:12:53", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:12:53', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067654b477d4bb
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6650,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:47:35', '067654b477d4bb', '6650', '20.00', '778', '0', '1', '758.00', '758', '0', '758', '1', '2024-12-20 14:12:54', '', '101', '0', 'ريم غانم k64', '2', '1', '3', '79', 'ريم غانم k64', '5' ,'0','','','','','-1','0','0','0','0','0','758','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '778', userid = '101' WHERE clientid = '6650';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6650','20.00','758','0','اضافة فاتورة مبيعات','150363', '778', '2024-12-20 14:12:54', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '758', '0', null, '0', null, null,'', '0','1','1','758','1','2024-12-20 12:47:35','0','0');
UPDATE client SET  inUse = 0 where clientid = 6650;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36108;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('170','07268', '150363', '5', '16377', '1', '220', '220', '0', '', '1', '2024-12-20 14:12:54', '16377', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36108-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 549318;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16377, '2024-12-20', 220, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '32', userid = '101', storedetaildate = '2024-12-20 14:12:54' WHERE storedetailid = '16376';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16377', '1', '1', '1', '150363', 'اضافة فاتورة مبيعات', 'sellbillController.php', '33', '32', '101', '2024-12-20 14:12:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35882;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('245','R3326', '150363', '1', '16281', '1', '290', '290', '0', '', '1', '2024-12-20 14:12:54', '16281', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35882-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 245.00 , meanbuyprice = 245.00, lastbuyprice_withDiscount = 245.00, meanbuyprice_withDiscount = 245.00
        , lastbuyprice_withTax = 245, meanbuyprice_withTax = 245, lastbuyprice_withDiscountAndTax = 245
                where sellbilldetailid = 549319;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16281, '2024-12-20', 290, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 245, 245, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+245
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 245, 245, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+245
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-20 14:12:54' WHERE storedetailid = '16280';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16281', '1', '1', '1', '150363', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '101', '2024-12-20 14:12:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36110;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('160','07271', '150363', '5', '16379', '1', '220', '220', '0', '', '1', '2024-12-20 14:12:54', '16379', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36110-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 163.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 163.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 162, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549320;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16379, '2024-12-20', 220, 165, 165
                    , 163, 165, 163, 161.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 162, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+163
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+163
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+161.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+162
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 165, 165
                    , 163, 165, 163, 161.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 162, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+163
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+163
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+161.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+162
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '39', userid = '101', storedetaildate = '2024-12-20 14:12:54' WHERE storedetailid = '16378';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16379', '1', '1', '1', '150363', 'اضافة فاتورة مبيعات', 'sellbillController.php', '40', '39', '101', '2024-12-20 14:12:54','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150363', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:12:54', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150363', '17', '10291', '1', '8', '8', '0', '', '1', '2024-12-20 14:12:54', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','8','8','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 79 where clientid = 6650;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 758, 580, 580
                    , 578, 580, 578, 576.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,580, 577, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+758, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+578
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+578
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+576.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+577
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6650, '2024-12-20', 758, 580, 580
                    , 578, 580, 578, 576.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,580, 577, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+758, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+578
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+578
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+576.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+577
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 758, 580, 580
                    , 578, 580, 578, 576.67, 580, 577)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+758, netSellCostBuyPrice = netSellCostBuyPrice+580
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+580
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+578
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+580
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+578
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+576.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+580
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+577;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067654b477d4bb and sellbillId = 150363 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:42:54";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:12:54", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:12:54', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:44:01";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:14:01", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:14:01', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067655f472028c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6167,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:12:55', '067655f472028c', '6167', '20.00', '565', '0', '1', '545.00', '545', '0', '545', '1', '2024-12-20 14:14:01', '', '101', '0', 'الاء يسري 73', '2', '1', '3', '79', 'الاء يسري 73', '3' ,'0','','','','','-1','0','0','0','0','0','545','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '565', userid = '101' WHERE clientid = '6167';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6167','20.00','545','0','اضافة فاتورة مبيعات','150364', '565', '2024-12-20 14:14:01', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '545', '0', null, '0', null, null,'', '0','1','1','545','1','2024-12-20 14:12:55','0','0');
UPDATE client SET  inUse = 0 where clientid = 6167;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36461;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('410','H1663', '150364', '14', '16471', '1', '520', '520', '0', '', '1', '2024-12-20 14:14:01', '16471', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36461-1,','1','1','0','0','520','520','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
        , lastbuyprice_withTax = 410, meanbuyprice_withTax = 410, lastbuyprice_withDiscountAndTax = 410
                where sellbilldetailid = 549323;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16471, '2024-12-20', 520, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 520, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '24', userid = '101', storedetaildate = '2024-12-20 14:14:01' WHERE storedetailid = '16470';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16471', '1', '1', '1', '150364', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '101', '2024-12-20 14:14:01','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150364', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:14:01', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150364', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-20 14:14:01', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','5','5','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 79 where clientid = 6167;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 545, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+545, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6167, '2024-12-20', 545, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+545, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 545, 410, 410
                    , 410, 410, 410, 410, 410, 410)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+545, netSellCostBuyPrice = netSellCostBuyPrice+410
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+410
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+410
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+410
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+410
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+410
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+410
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+410;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067655f472028c and sellbillId = 150364 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:44:02";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:14:02", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:14:02', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:45:50";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:15:50", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:15:50', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067655f8a9c65c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6413,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:14:02', '067655f8a9c65c', '6413', '20.00', '444', '0', '1', '424.00', '424', '0', '424', '1', '2024-12-20 14:15:50', '', '101', '0', 'فاطمه عبد العزيز73', '2', '1', '3', '79', 'فاطمه عبد العزيز73', '4' ,'0','','','','','-1','0','0','0','0','0','424','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '444', userid = '101' WHERE clientid = '6413';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6413','20.00','424','0','اضافة فاتورة مبيعات','150365', '444', '2024-12-20 14:15:50', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '424', '0', null, '0', null, null,'', '0','1','1','424','1','2024-12-20 14:14:02','0','0');
UPDATE client SET  inUse = 0 where clientid = 6413;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36121;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','10445', '150365', '5', '16347', '1', '200', '200', '0', '', '1', '2024-12-20 14:15:50', '16347', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36121-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 137.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 137.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 134, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549326;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16347, '2024-12-20', 200, 140, 140
                    , 137, 140, 137, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 134, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+137
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+137
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+134
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 137, 140, 137, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 134, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+137
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+137
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+134
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '101', storedetaildate = '2024-12-20 14:15:50' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '1', '1', '150365', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '101', '2024-12-20 14:15:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36128;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07264', '150365', '5', '16385', '1', '200', '200', '0', '', '1', '2024-12-20 14:15:50', '16385', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36128-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 70, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549327;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16385, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 70, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+70
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 70, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+70
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '101', storedetaildate = '2024-12-20 14:15:50' WHERE storedetailid = '16384';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16385', '1', '1', '1', '150365', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '101', '2024-12-20 14:15:50','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150365', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:15:50', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150365', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-20 14:15:50', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','4','4','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 79 where clientid = 6413;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 424, 280, 280
                    , 277, 280, 277, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 204, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+424, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+277
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+277
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+204
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6413, '2024-12-20', 424, 280, 280
                    , 277, 280, 277, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 204, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+424, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+277
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+277
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+204
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 424, 280, 280
                    , 277, 280, 277, 280, 280, 204)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+424, netSellCostBuyPrice = netSellCostBuyPrice+280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+277
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+277
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+280
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+280
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+204;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067655f8a9c65c and sellbillId = 150365 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:45:51";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:15:51", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:15:51', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:48:46";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:18:46", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:18:46', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067655efdb7ff3
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3108,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:11:41', '067655efdb7ff3', '3108', '-113.00', '3624', '0', '1', '3737.00', '3737', '0', '3737', '1', '2024-12-20 14:18:46', '', '75', '0', 'ام حمزة الاسماعلية Z19', '2', '1', '3', '98', 'ام حمزة الاسماعلية Z19', '14' ,'0','','','','','-1','0','0','0','0','0','3737','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '3624', userid = '75' WHERE clientid = '3108';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3108','-113.00','3737','0','اضافة فاتورة مبيعات','150366', '3624', '2024-12-20 14:18:46', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3737', '0', null, '0', null, null,'', '0','1','1','3737','1','2024-12-20 14:11:41','0','0');
UPDATE client SET  inUse = 0 where clientid = 3108;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('520','05984', '150366', '5', '13345', '1', '450', '450', '0', '', '1', '2024-12-20 14:18:46', '13345', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','450','450','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 520.00 , meanbuyprice = 520.00, lastbuyprice_withDiscount = 520.00, meanbuyprice_withDiscount = 520.00
        
                where sellbilldetailid = 549330;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13345, '2024-12-20', 450, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 450, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-8', userid = '75', storedetaildate = '2024-12-20 14:18:46' WHERE storedetailid = '13344';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13345', '1', '1', '1', '150366', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-7', '-8', '75', '2024-12-20 14:18:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35790;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','78808', '150366', '5', '15674', '1', '360', '360', '0', '', '1', '2024-12-20 14:18:46', '15674', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35790-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 295.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 295.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295
                where sellbilldetailid = 549331;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15674, '2024-12-20', 360, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '30', userid = '75', storedetaildate = '2024-12-20 14:18:46' WHERE storedetailid = '15673';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15674', '1', '1', '1', '150366', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31', '30', '75', '2024-12-20 14:18:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35873;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('420','07037', '150366', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-20 14:18:46', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35873-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 549332;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15995, '2024-12-20', 480, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 480, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '55', userid = '75', storedetaildate = '2024-12-20 14:18:46' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '150366', 'اضافة فاتورة مبيعات', 'sellbillController.php', '56', '55', '75', '2024-12-20 14:18:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32783;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('210','R3014', '150366', '1', '14638', '1', '215', '215', '0', '', '1', '2024-12-20 14:18:46', '14638', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32783-1,','1','1','0','0','215','215','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 206.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 206.00
        
                where sellbilldetailid = 549333;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14638, '2024-12-20', 215, 210, 210
                    , 206, 210, 206, 205.56
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+215, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+206
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+206
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+205.56
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 215, 210, 210
                    , 206, 210, 206, 205.56
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+215, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+206
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+206
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+205.56
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 14:18:46' WHERE storedetailid = '14637';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14638', '1', '1', '1', '150366', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-20 14:18:46','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','06302', '150366', '5', '14332', '1', '220', '220', '0', '', '1', '2024-12-20 14:18:46', '14332', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 138, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549334;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14332, '2024-12-20', 220, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 138, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+138
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 138, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+138
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 14:18:46' WHERE storedetailid = '14331';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14332', '1', '1', '1', '150366', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-20 14:18:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34420;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('265','06840', '150366', '5', '15572', '1', '185', '185', '0', '', '1', '2024-12-20 14:18:46', '15572', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34420-1,','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        
                where sellbilldetailid = 549335;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15572, '2024-12-20', 185, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 185, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 14:18:46' WHERE storedetailid = '15571';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15572', '1', '1', '1', '150366', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 14:18:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 34419;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('265','06838', '150366', '5', '15571', '2', '200', '400', '0', '', '1', '2024-12-20 14:18:46', '15571', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34419-2,','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        
                where sellbilldetailid = 549336;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15571, '2024-12-20', 400, 530, 530
                    , 530, 530, 530, 530
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+530
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 530, 530
                    , 530, 530, 530, 530
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+530
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 14:18:46' WHERE storedetailid = '15570';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15571', '1', '2', '1', '150366', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '2', '75', '2024-12-20 14:18:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35539;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('540','07046', '150366', '5', '16034', '1', '610', '610', '0', '', '1', '2024-12-20 14:18:47', '16034', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35539-1,','1','1','0','0','610','610','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 540.00 , meanbuyprice = 540.00, lastbuyprice_withDiscount = 540.00, meanbuyprice_withDiscount = 540.00
        , lastbuyprice_withTax = 540, meanbuyprice_withTax = 540, lastbuyprice_withDiscountAndTax = 540
                where sellbilldetailid = 549337;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16034, '2024-12-20', 610, 540, 540
                    , 540, 540, 540, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 540, 540, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+540
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+540
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+540
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+540
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 540, 540
                    , 540, 540, 540, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 540, 540, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+540
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+540
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+540
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+540
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '75', storedetaildate = '2024-12-20 14:18:47' WHERE storedetailid = '16033';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16034', '1', '1', '1', '150366', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-20 14:18:47','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('235','06835', '150366', '5', '15558', '1', '165', '165', '0', '', '1', '2024-12-20 14:18:47', '15558', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','165','165','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 235.00
        , lastbuyprice_withTax = 235, meanbuyprice_withTax = 141, lastbuyprice_withDiscountAndTax = 235
                where sellbilldetailid = 549338;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15558, '2024-12-20', 165, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 235, 141, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+141
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 165, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 141, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+141
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '75', storedetaildate = '2024-12-20 14:18:47' WHERE storedetailid = '15557';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15558', '1', '1', '1', '150366', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-20 14:18:47','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('320','06537', '150366', '5', '14964', '1', '200', '200', '0', '', '1', '2024-12-20 14:18:47', '14964', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
        
                where sellbilldetailid = 549339;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14964, '2024-12-20', 200, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 14:18:47' WHERE storedetailid = '14963';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14964', '1', '1', '1', '150366', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 14:18:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33820;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('430','06721', '150366', '5', '15250', '1', '395', '395', '0', '', '1', '2024-12-20 14:18:47', '15250', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33820-1,','1','1','0','0','395','395','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
        
                where sellbilldetailid = 549340;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15250, '2024-12-20', 395, 430, 430
                    , 430, 430, 430, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+395, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+430
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 395, 430, 430
                    , 430, 430, 430, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+395, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+430
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 14:18:47' WHERE storedetailid = '15249';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15250', '1', '1', '1', '150366', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 14:18:47','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150366', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:18:47', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150366', '17', '10291', '1', '37', '37', '0', '', '1', '2024-12-20 14:18:47', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','37','37','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 98 where clientid = 3108;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 3737, 4005, 4005
                    , 4001, 4005, 4001, 4000.56
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1730, 1534, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3737, sellCostBuyPrice =sellCostBuyPrice+4005
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4005, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4001
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4005, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4001
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+4000.56
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1730
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1534
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (3108, '2024-12-20', 3737, 4005, 4005
                    , 4001, 4005, 4001, 4000.56
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1730, 1534, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3737, sellCostBuyPrice =sellCostBuyPrice+4005
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4005, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4001
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4005, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4001
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+4000.56
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1730
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1534
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3737, 4005, 4005
                    , 4001, 4005, 4001, 4000.56, 1730, 1534)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3737, netSellCostBuyPrice = netSellCostBuyPrice+4005
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+4005
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+4001
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+4005
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+4001
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+4000.56
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1730
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1534;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067655efdb7ff3 and sellbillId = 150366 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:48:48";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:18:48", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:18:48', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:49:13";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:19:13", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:19:13', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067655ff7a30f5
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2258,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:15:51', '067655ff7a30f5', '2258', '0.00', '2757', '0', '1', '2757.00', '2757', '0', '2757', '1', '2024-12-20 14:19:13', '', '101', '0', 'ماجي محمد W3', '2', '1', '3', '79', 'ماجي محمد W3', '7' ,'0','','','','','-1','0','0','0','0','0','2757','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2757', userid = '101' WHERE clientid = '2258';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2258','0.00','2757','0','اضافة فاتورة مبيعات','150367', '2757', '2024-12-20 14:19:13', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2757', '0', null, '0', null, null,'', '0','1','1','2757','1','2024-12-20 14:15:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 2258;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36175;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('265','10747', '150367', '5', '16401', '1', '320', '320', '0', '', '1', '2024-12-20 14:19:13', '16401', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36175-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 265, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 549343;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16401, '2024-12-20', 320, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '101', storedetaildate = '2024-12-20 14:19:13' WHERE storedetailid = '16400';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16401', '1', '1', '1', '150367', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '101', '2024-12-20 14:19:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36346;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('400','R3319', '150367', '1', '16223', '1', '470', '470', '0', '', '1', '2024-12-20 14:19:13', '16223', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36346-1,','1','1','0','0','470','470','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549344;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16223, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '101', storedetaildate = '2024-12-20 14:19:13' WHERE storedetailid = '16222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16223', '1', '1', '1', '150367', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '101', '2024-12-20 14:19:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36459;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('525','H1666', '150367', '14', '16470', '1', '610', '610', '0', '', '1', '2024-12-20 14:19:13', '16470', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36459-1,','1','1','0','0','610','610','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 525.00 , meanbuyprice = 525.00, lastbuyprice_withDiscount = 525.00, meanbuyprice_withDiscount = 525.00
        , lastbuyprice_withTax = 525, meanbuyprice_withTax = 525, lastbuyprice_withDiscountAndTax = 525
                where sellbilldetailid = 549345;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16470, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 14:19:13' WHERE storedetailid = '16469';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16470', '1', '1', '1', '150367', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '101', '2024-12-20 14:19:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36146;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36159;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('585','H1644', '150367', '14', '16388', '2', '655', '1310', '0', '', '1', '2024-12-20 14:19:14', '16388', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36146-1,36159-1,','1','1','0','0','655','1310','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 585.00 , meanbuyprice = 585.00, lastbuyprice_withDiscount = 585.00, meanbuyprice_withDiscount = 585.00
        , lastbuyprice_withTax = 585, meanbuyprice_withTax = 585, lastbuyprice_withDiscountAndTax = 585
                where sellbilldetailid = 549346;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16388, '2024-12-20', 1310, 1170, 1170
                    , 1170, 1170, 1170, 1170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 1170, 1170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1310, sellCostBuyPrice =sellCostBuyPrice+1170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1310, 1170, 1170
                    , 1170, 1170, 1170, 1170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1170, 1170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1310, sellCostBuyPrice =sellCostBuyPrice+1170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '101', storedetaildate = '2024-12-20 14:19:14' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '2', '1', '150367', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '15', '101', '2024-12-20 14:19:14','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150367', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:19:14', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150367', '17', '10291', '1', '27', '27', '0', '', '1', '2024-12-20 14:19:14', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','27','27','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 79 where clientid = 2258;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2757, 2360, 2360
                    , 2360, 2360, 2360, 2360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2360, 2360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2757, sellCostBuyPrice =sellCostBuyPrice+2360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2258, '2024-12-20', 2757, 2360, 2360
                    , 2360, 2360, 2360, 2360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2360, 2360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2757, sellCostBuyPrice =sellCostBuyPrice+2360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2757, 2360, 2360
                    , 2360, 2360, 2360, 2360, 2360, 2360)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2757, netSellCostBuyPrice = netSellCostBuyPrice+2360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2360
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2360
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2360
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2360
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2360;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067655ff7a30f5 and sellbillId = 150367 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:49:14";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:19:14", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:19:14', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:49:20";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:19:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:19:20', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676558c052b72
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 13:45:04', '0676558c052b72', '1', '0.00', '0', '0', '1', '450.00', '450', '450', '0', '1', '2024-12-20 14:19:21', '', '104', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','450','0','','0','0','450','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150368', '0', '2024-12-20 14:19:21', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '450', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 13:45:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35151;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('385','R3292', '150368', '1', '15921', '1', '450', '450', '0', '', '1', '2024-12-20 14:19:21', '15921', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35151-1,','1','1','0','0','450','450','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 385.00 , meanbuyprice = 385.00, lastbuyprice_withDiscount = 385.00, meanbuyprice_withDiscount = 385.00
        , lastbuyprice_withTax = 385, meanbuyprice_withTax = 385, lastbuyprice_withDiscountAndTax = 385
                where sellbilldetailid = 549349;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15921, '2024-12-20', 450, 385, 385
                    , 385, 385, 385, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 385, 385, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+385
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 450, 385, 385
                    , 385, 385, 385, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 385, 385, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+385
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-20 14:19:21' WHERE storedetailid = '15920';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15921', '1', '1', '1', '150368', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-20 14:19:21','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '15870',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('15420','450', '0', '1', 'اضافة فاتورة مبيعات', '150368', '15870', '2024-12-20 14:19:21', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 24 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 450, 385, 385
                    , 385, 385, 385, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,385, 385, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+385
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 450, 385, 385
                    , 385, 385, 385, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,385, 385, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+385
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 450, 385, 385
                    , 385, 385, 385, 385, 385, 385)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+450, netSellCostBuyPrice = netSellCostBuyPrice+385
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+385
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+385
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+385
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+385
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+385
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+385
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+385;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676558c052b72 and sellbillId = 150368 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:49:21";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:19:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:19:21', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:49:33";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:19:33", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:19:33', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:49:45";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:19:45", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:19:45', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:50:11";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:20:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:20:11', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676560c9d88fe
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:19:21', '0676560c9d88fe', '1', '0.00', '0', '0', '1', '260.00', '260', '260', '0', '1', '2024-12-20 14:20:11', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','260','0','','0','0','260','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150369', '0', '2024-12-20 14:20:11', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '260', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:19:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35904;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','07235', '150369', '5', '16296', '1', '260', '260', '0', '', '1', '2024-12-20 14:20:11', '16296', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35904-1,','1','1','0','0','260','260','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 549350;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16296, '2024-12-20', 260, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 260, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '104', storedetaildate = '2024-12-20 14:20:11' WHERE storedetailid = '16295';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16296', '1', '1', '1', '150369', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-20 14:20:11','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '16130',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('15870','260', '0', '1', 'اضافة فاتورة مبيعات', '150369', '16130', '2024-12-20 14:20:11', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 97 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 260, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 260, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 260, 200, 200
                    , 200, 200, 200, 200, 200, 200)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+260, netSellCostBuyPrice = netSellCostBuyPrice+200
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+200
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+200
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+200
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+200
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+200;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676560c9d88fe and sellbillId = 150369 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:50:11";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:20:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:20:11', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:50:20";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:20:20", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:20:20', '101', 'editsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150367');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:51:04";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:21:04", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:21:04', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676560a833439
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10678,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:18:48', '0676560a833439', '10678', '0.00', '763', '0', '1', '763.00', '763', '0', '763', '1', '2024-12-20 14:21:04', '', '75', '0', 'محمد سلمان 52', '2', '1', '3', '98', 'محمد سلمان 52', '6' ,'0','','','','','-1','0','0','0','0','0','763','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '763', userid = '75' WHERE clientid = '10678';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10678','0.00','763','0','اضافة فاتورة مبيعات','150370', '763', '2024-12-20 14:21:04', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '763', '0', null, '0', null, null,'', '0','1','1','763','1','2024-12-20 14:18:48','0','0');
UPDATE client SET  inUse = 0 where clientid = 10678;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('230','R2956', '150370', '1', '14505', '1', '170', '170', '0', '', '1', '2024-12-20 14:21:04', '14505', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','170','170','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        
                where sellbilldetailid = 549351;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14505, '2024-12-20', 170, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 170, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '75', storedetaildate = '2024-12-20 14:21:04' WHERE storedetailid = '14504';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14505', '1', '1', '1', '150370', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-20 14:21:04','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','R2986', '150370', '1', '14588', '2', '200', '400', '0', '', '1', '2024-12-20 14:21:04', '14588', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 224.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 224.00
        
                where sellbilldetailid = 549352;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14588, '2024-12-20', 400, 450, 450
                    , 448, 450, 448, 447.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+448
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+448
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+447.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 450, 450
                    , 448, 450, 448, 447.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+448
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+448
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+447.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-16', userid = '75', storedetaildate = '2024-12-20 14:21:04' WHERE storedetailid = '14587';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14588', '1', '2', '1', '150370', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-14', '-16', '75', '2024-12-20 14:21:04','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','R2804', '150370', '1', '13984', '1', '165', '165', '0', '', '1', '2024-12-20 14:21:04', '13984', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','165','165','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        
                where sellbilldetailid = 549353;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13984, '2024-12-20', 165, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 165, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-20 14:21:04' WHERE storedetailid = '13983';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13984', '1', '1', '1', '150370', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-20 14:21:04','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150370', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:21:04', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150370', '17', '10291', '1', '8', '8', '0', '', '1', '2024-12-20 14:21:04', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','8','8','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 98 where clientid = 10678;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 763, 920, 920
                    , 918, 920, 918, 917.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+763, sellCostBuyPrice =sellCostBuyPrice+920
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+920, sellCostMeanBuyPrice = sellCostMeanBuyPrice+918
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+920, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+918
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+917.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10678, '2024-12-20', 763, 920, 920
                    , 918, 920, 918, 917.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+763, sellCostBuyPrice =sellCostBuyPrice+920
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+920, sellCostMeanBuyPrice = sellCostMeanBuyPrice+918
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+920, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+918
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+917.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 763, 920, 920
                    , 918, 920, 918, 917.34, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+763, netSellCostBuyPrice = netSellCostBuyPrice+920
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+920
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+918
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+920
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+918
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+917.34
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676560a833439 and sellbillId = 150370 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:51:05";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:21:05", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:21:05', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:52:17";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:22:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:22:17', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676560fc2fb8a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:20:12', '0676560fc2fb8a', '1', '0.00', '0', '0', '1', '1360.00', '1360', '1360', '0', '1', '2024-12-20 14:22:17', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1360','0','','0','0','1360','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150371', '0', '2024-12-20 14:22:17', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1360', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:20:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36469;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('335','07221', '150371', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-20 14:22:17', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36469-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 549356;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16279, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '59', userid = '104', storedetaildate = '2024-12-20 14:22:17' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150371', 'اضافة فاتورة مبيعات', 'sellbillController.php', '60', '59', '104', '2024-12-20 14:22:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35873;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('420','07037', '150371', '5', '15995', '2', '480', '960', '0', '', '1', '2024-12-20 14:22:18', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35873-2,','1','1','0','0','480','960','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 549357;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15995, '2024-12-20', 960, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+960, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 960, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+960, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '53', userid = '104', storedetaildate = '2024-12-20 14:22:18' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '2', '1', '150371', 'اضافة فاتورة مبيعات', 'sellbillController.php', '55', '53', '104', '2024-12-20 14:22:18','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '17490',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('16130','1360', '0', '1', 'اضافة فاتورة مبيعات', '150371', '17490', '2024-12-20 14:22:18', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 97 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1360, 1175, 1175
                    , 1175, 1175, 1175, 1175
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1175, 1163, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1360, sellCostBuyPrice =sellCostBuyPrice+1175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1175
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1175
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1175
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1175
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1163
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1360, 1175, 1175
                    , 1175, 1175, 1175, 1175
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1175, 1163, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1360, sellCostBuyPrice =sellCostBuyPrice+1175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1175
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1175
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1175
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1175
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1163
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1360, 1175, 1175
                    , 1175, 1175, 1175, 1175, 1175, 1163)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1360, netSellCostBuyPrice = netSellCostBuyPrice+1175
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1175
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1175
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1175
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1175
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1175
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1175
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1163;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676560fc2fb8a and sellbillId = 150371 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:52:18";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:22:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:22:18', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:53:14";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:23:14", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:23:14', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765613187771
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(539,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:21:05', '06765613187771', '539', '0.00', '838', '0', '1', '838.00', '838', '0', '838', '1', '2024-12-20 14:23:14', '', '75', '0', 'عزة محمود T71', '2', '1', '3', '98', 'عزة محمود T71', '6' ,'0','','','','','-1','0','0','0','0','0','838','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '838', userid = '75' WHERE clientid = '539';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('539','0.00','838','0','اضافة فاتورة مبيعات','150372', '838', '2024-12-20 14:23:14', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '838', '0', null, '0', null, null,'', '0','1','1','838','1','2024-12-20 14:21:05','0','0');
UPDATE client SET  inUse = 0 where clientid = 539;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36315;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07284', '150372', '5', '16415', '2', '200', '400', '0', '', '1', '2024-12-20 14:23:15', '16415', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36315-2,','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549358;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16415, '2024-12-20', 400, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '16', userid = '75', storedetaildate = '2024-12-20 14:23:15' WHERE storedetailid = '16414';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16415', '1', '2', '1', '150372', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '16', '75', '2024-12-20 14:23:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36142;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07226', '150372', '5', '16294', '1', '210', '210', '0', '', '1', '2024-12-20 14:23:15', '16294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36142-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 151.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 151.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 153, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549359;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16294, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '70', userid = '75', storedetaildate = '2024-12-20 14:23:15' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '1', '150372', 'اضافة فاتورة مبيعات', 'sellbillController.php', '71', '70', '75', '2024-12-20 14:23:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35923;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07206', '150372', '5', '16300', '1', '200', '200', '0', '', '1', '2024-12-20 14:23:15', '16300', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35923-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549360;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16300, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '36', userid = '75', storedetaildate = '2024-12-20 14:23:15' WHERE storedetailid = '16299';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16300', '1', '1', '1', '150372', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37', '36', '75', '2024-12-20 14:23:15','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150372', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:23:15', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150372', '17', '10291', '1', '8', '8', '0', '', '1', '2024-12-20 14:23:15', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','8','8','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 98 where clientid = 539;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 838, 575, 575
                    , 571, 575, 571, 573.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,575, 573, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+838, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+571
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+571
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+573.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+573
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (539, '2024-12-20', 838, 575, 575
                    , 571, 575, 571, 573.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,575, 573, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+838, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+571
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+571
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+573.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+573
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 838, 575, 575
                    , 571, 575, 571, 573.12, 575, 573)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+838, netSellCostBuyPrice = netSellCostBuyPrice+575
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+575
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+571
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+575
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+571
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+573.12
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+575
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+573;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765613187771 and sellbillId = 150372 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:53:15";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:23:15", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:23:15', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:53:33";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:23:33", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:23:33', '101', 'update', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 150367 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 150367 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150367;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 14:23:33', userid = '101',delbyuserid = '101', conditions = '1'  WHERE sellbillid = '150367';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36175;
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 265, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 549343;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16401, '2024-12-20', 320, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-320, sellCostBuyPrice =sellCostBuyPrice-265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-265, sellCostMeanBuyPrice = sellCostMeanBuyPrice-265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-265
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-320, sellCostBuyPrice =sellCostBuyPrice-265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-265, sellCostMeanBuyPrice = sellCostMeanBuyPrice-265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-265
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '13', userid = '101', storedetaildate = '2024-12-20 14:23:33' WHERE storedetailid = '16400';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16401', '1', '1', '0', '150367', 'تعديل فاتورة مبيعات', 'sellbillController.php', '12', '13', '101', '2024-12-20 14:15:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36346;
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549344;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16223, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-470, sellCostBuyPrice =sellCostBuyPrice-400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-400, sellCostMeanBuyPrice = sellCostMeanBuyPrice-400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-400
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-470, sellCostBuyPrice =sellCostBuyPrice-400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-400, sellCostMeanBuyPrice = sellCostMeanBuyPrice-400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-400
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '12', userid = '101', storedetaildate = '2024-12-20 14:23:33' WHERE storedetailid = '16222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16223', '1', '1', '0', '150367', 'تعديل فاتورة مبيعات', 'sellbillController.php', '11', '12', '101', '2024-12-20 14:15:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36459;
UPDATE sellbilldetail SET  lastbuyprice = 525.00 , meanbuyprice = 525.00, lastbuyprice_withDiscount = 525.00, meanbuyprice_withDiscount = 525.00
        , lastbuyprice_withTax = 525, meanbuyprice_withTax = 525, lastbuyprice_withDiscountAndTax = 525
                where sellbilldetailid = 549345;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16470, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-610, sellCostBuyPrice =sellCostBuyPrice-525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-525, sellCostMeanBuyPrice = sellCostMeanBuyPrice-525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-525
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-610, sellCostBuyPrice =sellCostBuyPrice-525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-525, sellCostMeanBuyPrice = sellCostMeanBuyPrice-525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-525
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 14:23:33' WHERE storedetailid = '16469';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16470', '1', '1', '0', '150367', 'تعديل فاتورة مبيعات', 'sellbillController.php', '1', '2', '101', '2024-12-20 14:15:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36146;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36159;
UPDATE sellbilldetail SET  lastbuyprice = 585.00 , meanbuyprice = 585.00, lastbuyprice_withDiscount = 585.00, meanbuyprice_withDiscount = 585.00
        , lastbuyprice_withTax = 585, meanbuyprice_withTax = 585, lastbuyprice_withDiscountAndTax = 585
                where sellbilldetailid = 549346;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16388, '2024-12-20', 1310, 1170, 1170
                    , 1170, 1170, 1170, 1170
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 1170, 1170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1310, sellCostBuyPrice =sellCostBuyPrice-1170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1170, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1170
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-2
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1310, 1170, 1170
                    , 1170, 1170, 1170, 1170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1170, 1170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1310, sellCostBuyPrice =sellCostBuyPrice-1170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1170, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1170
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '17', userid = '101', storedetaildate = '2024-12-20 14:23:33' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '2', '0', '150367', 'تعديل فاتورة مبيعات', 'sellbillController.php', '15', '17', '101', '2024-12-20 14:15:51','0','0');
CALL clientInUse(2258,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '101' WHERE clientid = '2258';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2258','2757.00','2757.00','1','تعديل فاتورة مبيعات','150367', '0', '2024-12-20 14:15:51', '101', 'sellbillController.php', 'تعديل فاتورة مبيعات', '2757', '0', null, '0', null, null,'', '0','1','1','2757','1','2024-12-20 14:15:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 2258;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2757, 2360, 2360
                    , 2360, 2360, 2360, 2360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2360, 2360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-2757, sellCostBuyPrice =sellCostBuyPrice-2360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-2360, sellCostMeanBuyPrice = sellCostMeanBuyPrice-2360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-2360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-2360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-2360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-2360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-2360
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2258, '2024-12-20', 2757, 2360, 2360
                    , 2360, 2360, 2360, 2360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2360, 2360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-2757, sellCostBuyPrice =sellCostBuyPrice-2360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-2360, sellCostMeanBuyPrice = sellCostMeanBuyPrice-2360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-2360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-2360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-2360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-2360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-2360
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2757, 2360, 2360
                    , 2360, 2360, 2360, 2360, 2360, 2360)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-2757, netSellCostBuyPrice = netSellCostBuyPrice-2360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-2360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-2360
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-2360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-2360
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-2360
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-2360
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-2360;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 150367 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 150367 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(2258,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:15:51', '067655ff7a30f5', '2258', '0.00', '3990', '0', '1', '3990', '3990', '0', '3990', '1', '2024-12-20 14:15:51', '', '101', '0', 'ماجي محمد W3', '2', '1', '3', '79', 'ماجي محمد W3', '11', '150367', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '3990', userid = '101' WHERE clientid = '2258';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2258','0.00','3990','0','اضافة فاتورة مبيعات (معدله)','150373', '3990', '2024-12-20 14:23:33', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '3990', '0', null, '0', null, null,'', '0','1','1','2757','1','2024-12-20 14:15:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 2258;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36175;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('265','10747', '150373', '5', '16401', '1', '320', '320', '0', '', '1', '2024-12-20 14:23:33', '16401', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36175-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 265, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 549363;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16401, '2024-12-20', 320, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '101', storedetaildate = '2024-12-20 14:23:33' WHERE storedetailid = '16400';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16401', '1', '1', '1', '150373', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '13', '12', '101', '2024-12-20 14:23:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36346;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('400','R3319', '150373', '1', '16223', '1', '470', '470', '0', '', '1', '2024-12-20 14:23:33', '16223', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36346-1,','1','1','0','0','470','470','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549364;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16223, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '101', storedetaildate = '2024-12-20 14:23:33' WHERE storedetailid = '16222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16223', '1', '1', '1', '150373', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '12', '11', '101', '2024-12-20 14:23:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36459;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('525','H1666', '150373', '14', '16470', '1', '610', '610', '0', '', '1', '2024-12-20 14:23:33', '16470', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36459-1,','1','1','0','0','610','610','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 525.00 , meanbuyprice = 525.00, lastbuyprice_withDiscount = 525.00, meanbuyprice_withDiscount = 525.00
        , lastbuyprice_withTax = 525, meanbuyprice_withTax = 525, lastbuyprice_withDiscountAndTax = 525
                where sellbilldetailid = 549365;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16470, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 14:23:33' WHERE storedetailid = '16469';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16470', '1', '1', '1', '150373', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '2', '1', '101', '2024-12-20 14:23:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36146;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('585','H1644', '150373', '14', '16388', '1', '700', '700', '0', '', '1', '2024-12-20 14:23:33', '16388', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36146-1,','1','1','0','0','700','700','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 585.00 , meanbuyprice = 585.00, lastbuyprice_withDiscount = 585.00, meanbuyprice_withDiscount = 585.00
        , lastbuyprice_withTax = 585, meanbuyprice_withTax = 585, lastbuyprice_withDiscountAndTax = 585
                where sellbilldetailid = 549366;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16388, '2024-12-20', 700, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+585
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+585
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 700, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0, 585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+585
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+585
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '16', userid = '101', storedetaildate = '2024-12-20 14:23:33' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '1', '1', '150373', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '17', '16', '101', '2024-12-20 14:23:33','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150373', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:23:33', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150373', '17', '10291', '1', '40', '40', '0', '', '1', '2024-12-20 14:23:33', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','40','40','0','','0','0.00','0','0','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36340;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('360','07290', '150373', '5', '16426', '1', '420', '420', '0', '', '1', '2024-12-20 14:23:33', '16426', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36340-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549369;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16426, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '101', storedetaildate = '2024-12-20 14:23:33' WHERE storedetailid = '16425';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16426', '1', '1', '1', '150373', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '12', '11', '101', '2024-12-20 14:23:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36162;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','07281', '150373', '5', '16397', '1', '310', '310', '0', '', '1', '2024-12-20 14:23:33', '16397', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36162-1,','1','1','0','0','310','310','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 125, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 549370;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16397, '2024-12-20', 310, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+125
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 310, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+125
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-20 14:23:33' WHERE storedetailid = '16396';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16397', '1', '1', '1', '150373', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '5', '4', '101', '2024-12-20 14:23:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36365;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','07293', '150373', '5', '16434', '1', '200', '200', '0', '', '1', '2024-12-20 14:23:33', '16434', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36365-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549371;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16434, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '101', storedetaildate = '2024-12-20 14:23:33' WHERE storedetailid = '16433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16434', '1', '1', '1', '150373', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '1', '0', '101', '2024-12-20 14:23:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35873;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('420','07037', '150373', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-20 14:23:33', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35873-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 549372;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15995, '2024-12-20', 480, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 480, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '52', userid = '101', storedetaildate = '2024-12-20 14:23:33' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '150373', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '53', '52', '101', '2024-12-20 14:23:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36418;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('340','H1667', '150373', '14', '16404', '1', '420', '420', '0', '', '1', '2024-12-20 14:23:34', '16404', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36418-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 340.00 , meanbuyprice = 340.00, lastbuyprice_withDiscount = 340.00, meanbuyprice_withDiscount = 340.00
        , lastbuyprice_withTax = 340, meanbuyprice_withTax = 340, lastbuyprice_withDiscountAndTax = 340
                where sellbilldetailid = 549373;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16404, '2024-12-20', 420, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+340
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+340
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '101', storedetaildate = '2024-12-20 14:23:34' WHERE storedetailid = '16403';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16404', '1', '1', '1', '150373', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '16', '15', '101', '2024-12-20 14:23:34','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 3990, 3290, 3290
                    , 3290, 3290, 3290, 3290
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3290, 3165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3990, sellCostBuyPrice =sellCostBuyPrice+3290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3290
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3290
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2258, '2024-12-20', 3990, 3290, 3290
                    , 3290, 3290, 3290, 3290
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3290, 3165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3990, sellCostBuyPrice =sellCostBuyPrice+3290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3290
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3290
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3990, 3290, 3290
                    , 3290, 3290, 3290, 3290, 3290, 3165)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3990, netSellCostBuyPrice = netSellCostBuyPrice+3290
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3290
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+3290
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3290
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+3290
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+3290
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+3290
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+3165;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150367 and newid=150373 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:53:34";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:23:34", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:23:34', '101', 'editprint', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150373');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:54:13";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:24:13", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:24:13', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:54:26";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:24:26", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:24:26', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:54:52";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:24:52", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:24:52', '101', 'editsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150363');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:55:05";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:25:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:25:05', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:55:37";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:55:42";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:25:42", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:25:42', '101', 'update', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 150363 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 150363 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150363;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 14:25:43', userid = '101',delbyuserid = '101', conditions = '1'  WHERE sellbillid = '150363';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36108;
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 549318;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16377, '2024-12-20', 220, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-220, sellCostBuyPrice =sellCostBuyPrice-170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-170, sellCostMeanBuyPrice = sellCostMeanBuyPrice-170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-170
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-220, sellCostBuyPrice =sellCostBuyPrice-170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-170, sellCostMeanBuyPrice = sellCostMeanBuyPrice-170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-170
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '33', userid = '101', storedetaildate = '2024-12-20 14:25:43' WHERE storedetailid = '16376';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16377', '1', '1', '0', '150363', 'تعديل فاتورة مبيعات', 'sellbillController.php', '32', '33', '101', '2024-12-20 12:47:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35882;
UPDATE sellbilldetail SET  lastbuyprice = 245.00 , meanbuyprice = 245.00, lastbuyprice_withDiscount = 245.00, meanbuyprice_withDiscount = 245.00
        , lastbuyprice_withTax = 245, meanbuyprice_withTax = 245, lastbuyprice_withDiscountAndTax = 245
                where sellbilldetailid = 549319;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16281, '2024-12-20', 290, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 245, 245, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-290, sellCostBuyPrice =sellCostBuyPrice-245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-245, sellCostMeanBuyPrice = sellCostMeanBuyPrice-245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-245
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 245, 245, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-290, sellCostBuyPrice =sellCostBuyPrice-245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-245, sellCostMeanBuyPrice = sellCostMeanBuyPrice-245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-245
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '5', userid = '101', storedetaildate = '2024-12-20 14:25:43' WHERE storedetailid = '16280';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16281', '1', '1', '0', '150363', 'تعديل فاتورة مبيعات', 'sellbillController.php', '4', '5', '101', '2024-12-20 12:47:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36110;
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 163.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 163.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 162, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549320;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16379, '2024-12-20', 220, 165, 165
                    , 163, 165, 163, 161.67
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 165, 162, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-220, sellCostBuyPrice =sellCostBuyPrice-165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-165, sellCostMeanBuyPrice = sellCostMeanBuyPrice-163
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-163
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-161.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-162
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 165, 165
                    , 163, 165, 163, 161.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 162, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-220, sellCostBuyPrice =sellCostBuyPrice-165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-165, sellCostMeanBuyPrice = sellCostMeanBuyPrice-163
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-163
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-161.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-162
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '40', userid = '101', storedetaildate = '2024-12-20 14:25:43' WHERE storedetailid = '16378';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16379', '1', '1', '0', '150363', 'تعديل فاتورة مبيعات', 'sellbillController.php', '39', '40', '101', '2024-12-20 12:47:35','0','0');
CALL clientInUse(6650,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '20', userid = '101' WHERE clientid = '6650';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6650','778.00','758.00','1','تعديل فاتورة مبيعات','150363', '20', '2024-12-20 12:47:35', '101', 'sellbillController.php', 'تعديل فاتورة مبيعات', '758', '0', null, '0', null, null,'', '0','1','1','758','1','2024-12-20 12:47:35','0','0');
UPDATE client SET  inUse = 0 where clientid = 6650;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 758, 580, 580
                    , 578, 580, 578, 576.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,580, 577, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-758, sellCostBuyPrice =sellCostBuyPrice-580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-580, sellCostMeanBuyPrice = sellCostMeanBuyPrice-578
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-578
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-576.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-577
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6650, '2024-12-20', 758, 580, 580
                    , 578, 580, 578, 576.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 580, 577, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-758, sellCostBuyPrice =sellCostBuyPrice-580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-580, sellCostMeanBuyPrice = sellCostMeanBuyPrice-578
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-578
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-576.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-577
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 758, 580, 580
                    , 578, 580, 578, 576.67, 580, 577)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-758, netSellCostBuyPrice = netSellCostBuyPrice-580
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-580
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-578
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-580
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-578
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-576.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-580
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-577;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 150363 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 150363 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(6650,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:47:35', '067654b477d4bb', '6650', '20.00', '1000', '0', '1', '980', '980', '0', '980', '1', '2024-12-20 12:47:35', '', '101', '0', 'ريم غانم k64', '2', '1', '3', '79', 'ريم غانم k64', '6', '150363', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1000', userid = '101' WHERE clientid = '6650';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6650','20.00','980','0','اضافة فاتورة مبيعات (معدله)','150374', '1000', '2024-12-20 14:25:43', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '980', '0', null, '0', null, null,'', '0','1','1','758','1','2024-12-20 12:47:35','0','0');
UPDATE client SET  inUse = 0 where clientid = 6650;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36108;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('170','07268', '150374', '5', '16377', '1', '220', '220', '0', '', '1', '2024-12-20 14:25:43', '16377', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36108-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 549374;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16377, '2024-12-20', 220, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '32', userid = '101', storedetaildate = '2024-12-20 14:25:43' WHERE storedetailid = '16376';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16377', '1', '1', '1', '150374', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '33', '32', '101', '2024-12-20 14:25:43','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35882;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('245','R3326', '150374', '1', '16281', '1', '290', '290', '0', '', '1', '2024-12-20 14:25:43', '16281', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35882-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 245.00 , meanbuyprice = 245.00, lastbuyprice_withDiscount = 245.00, meanbuyprice_withDiscount = 245.00
        , lastbuyprice_withTax = 245, meanbuyprice_withTax = 245, lastbuyprice_withDiscountAndTax = 245
                where sellbilldetailid = 549375;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16281, '2024-12-20', 290, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 245, 245, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+245
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 245, 245, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+245
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-20 14:25:43' WHERE storedetailid = '16280';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16281', '1', '1', '1', '150374', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '5', '4', '101', '2024-12-20 14:25:43','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36110;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('160','07271', '150374', '5', '16379', '2', '220', '440', '0', '', '1', '2024-12-20 14:25:43', '16379', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36110-2,','1','1','0','0','220','440','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 163.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 163.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 162, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549376;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16379, '2024-12-20', 440, 330, 330
                    , 326, 330, 326, 323.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 330, 324, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+326
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+326
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+323.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+324
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 440, 330, 330
                    , 326, 330, 326, 323.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 330, 324, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+326
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+326
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+323.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+324
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '38', userid = '101', storedetaildate = '2024-12-20 14:25:43' WHERE storedetailid = '16378';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16379', '1', '2', '1', '150374', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '40', '38', '101', '2024-12-20 14:25:43','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150374', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:25:43', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150374', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-20 14:25:43', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','10','10','0','','0','0.00','0','0','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 980, 745, 745
                    , 741, 745, 741, 738.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,745, 739, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+980, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+741
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+741
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+738.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+739
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6650, '2024-12-20', 980, 745, 745
                    , 741, 745, 741, 738.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,745, 739, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+980, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+741
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+741
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+738.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+739
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 980, 745, 745
                    , 741, 745, 741, 738.34, 745, 739)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+980, netSellCostBuyPrice = netSellCostBuyPrice+745
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+745
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+741
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+745
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+741
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+738.34
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+745
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+739;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150363 and newid=150374 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:55:43";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:25:43", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:25:43', '101', 'editprint', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150374');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:55:44";
UPDATE user SET loginip = "192.168.1.31", lastactivetime = "2024-12-20 14:25:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 14:25:44', '2', '', '192.168.1.31', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:55:45";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:55:50";
UPDATE user SET loginip = "192.168.1.31", lastactivetime = "2024-12-20 14:25:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 14:25:50', '2', '', '192.168.1.31', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:56:01";
UPDATE user SET loginip = "192.168.1.31", lastactivetime = "2024-12-20 14:26:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 14:26:01', '2', 'show', '192.168.1.31', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:56:19";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:26:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:26:19', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'فرق فاتورة', '', '20', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '17470',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('17490.00','20', '1', '1', 'إضافة مصروف', '25905', '17470', '2024-12-20 14:26:19', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'فرق فاتورة', expensesdetails = '', expensesValue = '20.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25905';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:56:20";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:26:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:26:20', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:56:22";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:56:22";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:26:22", deviceType = "DESKTOP" WHERE userid = 104;
UPDATE user SET loginip = "192.168.1.31", lastactivetime = "2024-12-20 14:26:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:26:22', '2', 'showDetail', '192.168.1.31', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=148794');
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:26:22', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:56:34";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:26:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:26:34', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:57:10";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:27:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 14:27:10', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:57:19";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:27:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:27:19', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('مريم نصحي 52' , '', '', '01011164496', '0', '', '0', '2024-12-20 14:28:40', '104', '0','','0','','-10','0','0',',','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10764', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10764','0','0','0','إضافة عميل جديد','10764', '0', '2024-12-20 14:28:40', '104', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('مريم نصحي 52', 'مريم نصحي 52', 'مريم نصحي 52', 'مريم نصحي 52', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '104', '0', '2024-12-20 14:28:40');
UPDATE client SET clientname = 'مريم نصحي 52', clientaddress = '', clientphone = '', clientmobile = '01011164496', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '104'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='0' , typeclientid=',',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12601',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10764';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 10:59:59";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:29:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:29:59', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676562a73810a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10764,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:27:19', '0676562a73810a', '10764', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2024-12-20 14:29:59', '', '104', '0', 'مريم نصحي 52', '1', '1', '3', '5', 'مريم نصحي 52', '1' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '10764';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10764','0.00','0','0','اضافة فاتورة مبيعات','150375', '0', '2024-12-20 14:29:59', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:27:19','0','0');
UPDATE client SET  inUse = 0 where clientid = 10764;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35886;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('165','07219', '150375', '5', '16284', '1', '200', '200', '0', '', '1', '2024-12-20 14:29:59', '16284', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35886-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549379;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16284, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '104', storedetaildate = '2024-12-20 14:29:59' WHERE storedetailid = '16283';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16284', '1', '1', '1', '150375', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-20 14:29:59','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '17670',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('17470','200', '0', '1', 'اضافة فاتورة مبيعات', '150375', '17670', '2024-12-20 14:29:59', '104',  'sellbillController.php','10764','','0');
UPDATE client SET  delegateid = 5 where clientid = 10764;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10764, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 200, 165, 165
                    , 165, 165, 165, 165, 165, 165)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+165
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+165
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+165
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+165
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+165
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+165
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+165
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+165;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676562a73810a and sellbillId = 150375 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:00:00";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:30:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:30:00', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:00:20";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:30:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:30:20', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247853
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10764,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-200' , clientdate = '2024-12-20 14:30:20', userid = '2' WHERE clientid = '10764';
UPDATE client SET  inUse = 0 where clientid = 10764;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10764','0.00','200','1','ايصال تحصيل (( قبض من عميل ))','247853', '-200', '2024-12-20 13:24:22', '2', 'clientPayedDeptController.php', '   ', '200', '0', null, '0', null, null,'', '-1','1','1','200','1','','3623','0');
UPDATE save SET  savecurrentvalue = '91681.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('91481.50','200', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247881', '91681.5', '2024-12-20 14:30:20', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '200', '200', '2024-12-20', '2', '0', '0', '2024-12-20 14:30:20','اضافة ايصال سداد للعميل مريم نصحي 52','1','0','0','0','247881','clientPayedDeptController.php?do=show&id=247881');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122283', '-1', '200', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '200', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122283', '12601', '200', '','0');
UPDATE accountstree SET name = 'مريم نصحي 52', customName = 'مريم نصحي 52', customNameEn = 'مريم نصحي 52', nameEn = 'مريم نصحي 52', parent = '58', accountNature = '0', theValue = '-200', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '104', del = '0', sysdate = '2024-12-20 14:28:40' WHERE id = '12601';
UPDATE clientdebtchange SET clientid = '10764', clientdebtchangebefore = '0.000', clientdebtchangeamount = '200.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247853', clientdebtchangeafter = '-200.000', clientdebtchangedate = '2024-12-20 13:24:22', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '200.00',discount='', reciptid='0', dailyentryid = '122283',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='200',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247881';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247853 -clientdebtchangeId = 247881
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:00:21";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:30:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:30:21', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:01:14";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:31:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 14:31:14', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:01:39";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:31:39", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:31:39', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676560c2d96bb
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(311,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:19:14', '0676560c2d96bb', '311', '0.00', '1586', '0', '1', '1586.00', '1586', '0', '1586', '1', '2024-12-20 14:31:40', '', '101', '0', 'اسراء احمد K283', '2', '1', '3', '79', 'اسراء احمد K283', '7' ,'0','','','','','-1','0','0','0','0','0','1586','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1586', userid = '101' WHERE clientid = '311';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('311','0.00','1586','0','اضافة فاتورة مبيعات','150376', '1586', '2024-12-20 14:31:40', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1586', '0', null, '0', null, null,'', '0','1','1','1586','1','2024-12-20 14:19:14','0','0');
UPDATE client SET  inUse = 0 where clientid = 311;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36187;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','06958', '150376', '5', '15855', '1', '210', '210', '0', '', '1', '2024-12-20 14:31:40', '15855', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36187-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549380;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15855, '2024-12-20', 210, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '21', userid = '101', storedetaildate = '2024-12-20 14:31:40' WHERE storedetailid = '15854';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15855', '1', '1', '1', '150376', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '101', '2024-12-20 14:31:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35609;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('210','07130', '150376', '5', '16158', '1', '260', '260', '0', '', '1', '2024-12-20 14:31:40', '16158', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35609-1,','1','1','0','0','260','260','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where sellbilldetailid = 549381;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16158, '2024-12-20', 260, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+210
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+210
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 260, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+210
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+210
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '101', storedetaildate = '2024-12-20 14:31:40' WHERE storedetailid = '16157';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16158', '1', '1', '1', '150376', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '101', '2024-12-20 14:31:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35454;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('265','95061', '150376', '5', '16062', '1', '330', '330', '0', '', '1', '2024-12-20 14:31:40', '16062', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35454-1,','1','1','0','0','330','330','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 265, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 549382;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16062, '2024-12-20', 330, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 330, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '101', storedetaildate = '2024-12-20 14:31:40' WHERE storedetailid = '16061';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16062', '1', '1', '1', '150376', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '101', '2024-12-20 14:31:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35387;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('360','H1512', '150376', '14', '15982', '1', '430', '430', '0', '', '1', '2024-12-20 14:31:40', '15982', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35387-1,','1','1','0','0','430','430','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 361.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 361.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 362, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549383;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15982, '2024-12-20', 430, 360, 360
                    , 361, 360, 361, 362
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 362, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+361
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+361
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+362
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+362
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 430, 360, 360
                    , 361, 360, 361, 362
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 362, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+361
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+361
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+362
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+362
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '101', storedetaildate = '2024-12-20 14:31:40' WHERE storedetailid = '15981';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15982', '1', '1', '1', '150376', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '101', '2024-12-20 14:31:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34530;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','H1398', '150376', '14', '15644', '1', '320', '320', '0', '', '1', '2024-12-20 14:31:40', '15644', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34530-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 549384;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15644, '2024-12-20', 320, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-20 14:31:40' WHERE storedetailid = '15643';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15644', '1', '1', '1', '150376', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '101', '2024-12-20 14:31:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150376', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:31:40', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150376', '17', '10291', '1', '16', '16', '0', '', '1', '2024-12-20 14:31:40', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','16','16','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 79 where clientid = 311;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1586, 1230, 1230
                    , 1231, 1230, 1231, 1232
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1230, 1232, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1586, sellCostBuyPrice =sellCostBuyPrice+1230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1232
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1232
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (311, '2024-12-20', 1586, 1230, 1230
                    , 1231, 1230, 1231, 1232
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1230, 1232, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1586, sellCostBuyPrice =sellCostBuyPrice+1230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1232
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1232
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1586, 1230, 1230
                    , 1231, 1230, 1231, 1232, 1230, 1232)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1586, netSellCostBuyPrice = netSellCostBuyPrice+1230
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1230
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1231
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1230
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1231
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1232
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1230
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1232;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676560c2d96bb and sellbillId = 150376 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:01:41";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:31:41", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:31:41', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:01:56";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:31:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:31:56', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:01:59";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:31:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:31:59', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067655d4c5b516
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:04:28', '067655d4c5b516', '1', '0.00', '0', '0', '1', '2333.00', '2333', '2333', '0', '1', '2024-12-20 14:31:59', '', '104', '0', 'نقدي', '1', '0', '3', '93', 'نقدي', '13' ,'0','','','','','-1','0','0','0','0','0','2333','0','','0','0','2333','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150377', '0', '2024-12-20 14:31:59', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2333', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:04:28','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('265','06155', '150377', '5', '13933', '1', '190', '190', '0', '', '1', '2024-12-20 14:31:59', '13933', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','190','190','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 285.00 , meanbuyprice = 279.00, lastbuyprice_withDiscount = 285.00, meanbuyprice_withDiscount = 279.00
        
                where sellbilldetailid = 549387;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13933, '2024-12-20', 190, 265, 285
                    , 279, 285, 279, 277.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+279
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+279
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+277.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 190, 265, 285
                    , 279, 285, 279, 277.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+279
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+279
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+277.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '104', storedetaildate = '2024-12-20 14:31:59' WHERE storedetailid = '13932';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13933', '1', '1', '1', '150377', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-20 14:31:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29858;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('410','05947', '150377', '5', '13261', '1', '265', '265', '0', '', '1', '2024-12-20 14:31:59', '13261', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29858-1,','1','1','0','0','265','265','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 406.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 406.00
        
                where sellbilldetailid = 549388;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13261, '2024-12-20', 265, 410, 410
                    , 406, 410, 406, 405
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+265, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+406
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+406
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+405
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 265, 410, 410
                    , 406, 410, 406, 405
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+265, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+406
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+406
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+405
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-20 14:31:59' WHERE storedetailid = '13260';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13261', '1', '1', '1', '150377', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-20 14:31:59','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('320','05882', '150377', '5', '13124', '2', '180', '360', '0', '', '1', '2024-12-20 14:31:59', '13124', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','180','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
        
                where sellbilldetailid = 549389;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13124, '2024-12-20', 360, 640, 640
                    , 640, 640, 640, 640
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+640
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+640
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+640
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 640, 640
                    , 640, 640, 640, 640
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+640
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+640
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+640
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '104', storedetaildate = '2024-12-20 14:31:59' WHERE storedetailid = '13123';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13124', '1', '2', '1', '150377', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '0', '104', '2024-12-20 14:31:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30598;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('445','06093', '150377', '5', '13754', '1', '295', '295', '0', '', '1', '2024-12-20 14:31:59', '13754', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30598-1,','1','1','0','0','295','295','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 445.00 , meanbuyprice = 445.00, lastbuyprice_withDiscount = 445.00, meanbuyprice_withDiscount = 445.00
        
                where sellbilldetailid = 549390;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13754, '2024-12-20', 295, 445, 445
                    , 445, 445, 445, 445
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+295, sellCostBuyPrice =sellCostBuyPrice+445
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+445, sellCostMeanBuyPrice = sellCostMeanBuyPrice+445
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+445, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+445
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+445
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 295, 445, 445
                    , 445, 445, 445, 445
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+295, sellCostBuyPrice =sellCostBuyPrice+445
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+445, sellCostMeanBuyPrice = sellCostMeanBuyPrice+445
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+445, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+445
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+445
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '104', storedetaildate = '2024-12-20 14:31:59' WHERE storedetailid = '13753';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13754', '1', '1', '1', '150377', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-20 14:31:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33821;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('235','06628', '150377', '5', '15138', '1', '220', '220', '0', '', '1', '2024-12-20 14:31:59', '15138', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33821-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 235.00
        
                where sellbilldetailid = 549391;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15138, '2024-12-20', 220, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '104', storedetaildate = '2024-12-20 14:31:59' WHERE storedetailid = '15137';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15138', '1', '1', '1', '150377', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '104', '2024-12-20 14:31:59','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('450','05886', '150377', '5', '13125', '1', '280', '280', '0', '', '1', '2024-12-20 14:31:59', '13125', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','280','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
        
                where sellbilldetailid = 549392;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13125, '2024-12-20', 280, 450, 450
                    , 450, 450, 450, 450
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+450
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 280, 450, 450
                    , 450, 450, 450, 450
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+450
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '104', storedetaildate = '2024-12-20 14:31:59' WHERE storedetailid = '13124';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13125', '1', '1', '1', '150377', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '104', '2024-12-20 14:31:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32849;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('150','06490', '150377', '5', '14812', '1', '145', '145', '0', '', '1', '2024-12-20 14:31:59', '14812', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32849-1,','1','1','0','0','145','145','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 713.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 713.00
        
                where sellbilldetailid = 549393;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14812, '2024-12-20', 145, 150, 150
                    , 713, 150, 713, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+145, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+713
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+713
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 145, 150, 150
                    , 713, 150, 713, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+145, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+713
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+713
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '104', storedetaildate = '2024-12-20 14:31:59' WHERE storedetailid = '14811';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14812', '1', '1', '1', '150377', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-20 14:31:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33581;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('135','06661', '150377', '5', '15151', '1', '100', '100', '0', '', '1', '2024-12-20 14:31:59', '15151', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33581-1,','1','1','0','0','100','100','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 135.00 , meanbuyprice = 135.00, lastbuyprice_withDiscount = 135.00, meanbuyprice_withDiscount = 135.00
        
                where sellbilldetailid = 549394;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15151, '2024-12-20', 100, 135, 135
                    , 135, 135, 135, 135
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, sellCostBuyPrice =sellCostBuyPrice+135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+135, sellCostMeanBuyPrice = sellCostMeanBuyPrice+135
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+135
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+135
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 100, 135, 135
                    , 135, 135, 135, 135
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, sellCostBuyPrice =sellCostBuyPrice+135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+135, sellCostMeanBuyPrice = sellCostMeanBuyPrice+135
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+135
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+135
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-20 14:31:59' WHERE storedetailid = '15150';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15151', '1', '1', '1', '150377', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-20 14:31:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31950;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('260','0K738', '150377', '7', '14364', '1', '140', '140', '0', '', '1', '2024-12-20 14:31:59', '14364', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31950-1,','1','1','0','0','140','140','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 260.00
        
                where sellbilldetailid = 549395;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14364, '2024-12-20', 140, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+140, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 140, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+140, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '104', storedetaildate = '2024-12-20 14:31:59' WHERE storedetailid = '14363';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14364', '1', '1', '1', '150377', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-20 14:31:59','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('50','000M1', '150377', '1', '4724', '1', '135', '135', '0', '', '1', '2024-12-20 14:31:59', '4724', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','135','135','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 50.00 , meanbuyprice = 50.00, lastbuyprice_withDiscount = 50.00, meanbuyprice_withDiscount = 50.00
        
                where sellbilldetailid = 549396;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4724, '2024-12-20', 135, 50, 50
                    , 50, 50, 50, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+135, sellCostBuyPrice =sellCostBuyPrice+50
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+50, sellCostMeanBuyPrice = sellCostMeanBuyPrice+50
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+50, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+50
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 135, 50, 50
                    , 50, 50, 50, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+135, sellCostBuyPrice =sellCostBuyPrice+50
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+50, sellCostMeanBuyPrice = sellCostMeanBuyPrice+50
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+50, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+50
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-148', userid = '104', storedetaildate = '2024-12-20 14:31:59' WHERE storedetailid = '4723';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('4724', '1', '1', '1', '150377', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-147', '-148', '104', '2024-12-20 14:31:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 23773;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('320','05073', '150377', '5', '10915', '1', '190', '190', '0', '', '1', '2024-12-20 14:31:59', '10915', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','23773-1,','1','1','0','0','190','190','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 391.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 391.00
        
                where sellbilldetailid = 549397;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10915, '2024-12-20', 190, 320, 320
                    , 391, 320, 391, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+391
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+391
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 190, 320, 320
                    , 391, 320, 391, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+391
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+391
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '104', storedetaildate = '2024-12-20 14:31:59' WHERE storedetailid = '10914';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10915', '1', '1', '1', '150377', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-20 14:31:59','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150377', '17', '10291', '1', '13', '13', '0', '', '1', '2024-12-20 14:31:59', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','13','13','0','','0','0.00','0','0','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20003',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('17670','2333', '0', '1', 'اضافة فاتورة مبيعات', '150377', '20003', '2024-12-20 14:31:59', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 93 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2333, 3360, 3380
                    , 4004, 3380, 4004, 3317.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2333, sellCostBuyPrice =sellCostBuyPrice+3360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4004
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4004
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3317.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 2333, 3360, 3380
                    , 4004, 3380, 4004, 3317.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2333, sellCostBuyPrice =sellCostBuyPrice+3360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4004
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4004
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3317.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2333, 3360, 3380
                    , 4004, 3380, 4004, 3317.5, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2333, netSellCostBuyPrice = netSellCostBuyPrice+3360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3380
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+4004
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3380
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+4004
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+3317.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067655d4c5b516 and sellbillId = 150377 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:02:00";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:32:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:32:00', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:02:06";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:32:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:32:06', '2', 'editsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150375');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:02:19";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:32:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:32:19', '2', 'update', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 150375 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 150375 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150375;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 14:32:19', userid = '104',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '150375';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35886;
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549379;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16284, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-200, sellCostBuyPrice =sellCostBuyPrice-165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-165, sellCostMeanBuyPrice = sellCostMeanBuyPrice-165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-165
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-200, sellCostBuyPrice =sellCostBuyPrice-165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-165, sellCostMeanBuyPrice = sellCostMeanBuyPrice-165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-165
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '9', userid = '2', storedetaildate = '2024-12-20 14:32:19' WHERE storedetailid = '16283';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16284', '1', '1', '0', '150375', 'تعديل فاتورة مبيعات', 'sellbillController.php', '8', '9', '2', '2024-12-20 14:27:19','0','0');
CALL clientInUse(10764,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-200', userid = '2' WHERE clientid = '10764';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10764','-200.00','0.00','1','تعديل فاتورة مبيعات','150375', '-200', '2024-12-20 14:27:19', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:27:19','0','0');
UPDATE client SET  inUse = 0 where clientid = 10764;
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '19803',  userid = '2' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('20003','200', '1', '1', 'تعديل فاتورة مبيعات', '150375', '19803', '2024-12-20 14:32:19', '2',  'sellbillController.php','10764','','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-200, sellCostBuyPrice =sellCostBuyPrice-165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-165, sellCostMeanBuyPrice = sellCostMeanBuyPrice-165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-165
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10764, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-200, sellCostBuyPrice =sellCostBuyPrice-165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-165, sellCostMeanBuyPrice = sellCostMeanBuyPrice-165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-165
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 200, 165, 165
                    , 165, 165, 165, 165, 165, 165)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-200, netSellCostBuyPrice = netSellCostBuyPrice-165
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-165
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-165
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-165
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-165
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-165
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-165
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-165;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 150375 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 150375 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(10764,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:27:19', '0676562a73810a', '10764', '-200.00', '0', '0', '1', '200', '200', '0', '200', '1', '2024-12-20 14:27:19', '', '2', '0', 'مريم نصحي 52', '1', '1', '3', '5', 'مريم نصحي 52', '1', '150375', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '2' WHERE clientid = '10764';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10764','-200.00','200','0','اضافة فاتورة مبيعات (معدله)','150378', '0', '2024-12-20 14:32:19', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:27:19','0','0');
UPDATE client SET  inUse = 0 where clientid = 10764;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35886;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('165','07219', '150378', '5', '16284', '1', '200', '200', '0', '', '1', '2024-12-20 14:32:19', '16284', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35886-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549399;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16284, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '2', storedetaildate = '2024-12-20 14:32:19' WHERE storedetailid = '16283';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16284', '1', '1', '1', '150378', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '9', '8', '2', '2024-12-20 14:32:19','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10764, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 200, 165, 165
                    , 165, 165, 165, 165, 165, 165)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+165
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+165
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+165
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+165
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+165
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+165
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+165
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+165;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150375 and newid=150378 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:02:20";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:32:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:32:20', '2', 'editprint', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150378');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:02:30";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:32:30", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:32:30', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676561b402da8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1207,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:23:16', '0676561b402da8', '1207', '0.00', '3172', '0', '1', '3172.00', '3172', '0', '3172', '1', '2024-12-20 14:32:30', '', '75', '0', 'محل روني D16', '2', '1', '3', '81', 'محل روني D16', '11' ,'0','','','','','-1','0','0','0','0','0','3172','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '3172', userid = '75' WHERE clientid = '1207';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1207','0.00','3172','0','اضافة فاتورة مبيعات','150379', '3172', '2024-12-20 14:32:30', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3172', '0', null, '0', null, null,'', '0','1','1','3172','1','2024-12-20 14:23:16','0','0');
UPDATE client SET  inUse = 0 where clientid = 1207;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35983;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('405','H1628', '150379', '14', '16328', '1', '500', '500', '0', '', '1', '2024-12-20 14:32:30', '16328', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35983-1,','1','1','0','0','500','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 405.00 , meanbuyprice = 405.00, lastbuyprice_withDiscount = 405.00, meanbuyprice_withDiscount = 405.00
        , lastbuyprice_withTax = 405, meanbuyprice_withTax = 405, lastbuyprice_withDiscountAndTax = 405
                where sellbilldetailid = 549400;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16328, '2024-12-20', 500, 405, 405
                    , 405, 405, 405, 405
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 405, 405, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+405
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+405, sellCostMeanBuyPrice = sellCostMeanBuyPrice+405
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+405, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+405
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+405
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+405
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+405
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 500, 405, 405
                    , 405, 405, 405, 405
                    , 0, 0, 0, 0
                    , 0, 0, 0, 405, 405, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+405
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+405, sellCostMeanBuyPrice = sellCostMeanBuyPrice+405
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+405, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+405
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+405
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+405
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+405
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '75', storedetaildate = '2024-12-20 14:32:30' WHERE storedetailid = '16327';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16328', '1', '1', '1', '150379', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-20 14:32:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35842;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','06872', '150379', '5', '15654', '1', '360', '360', '0', '', '1', '2024-12-20 14:32:30', '15654', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35842-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 356.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 356.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 356, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 549401;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15654, '2024-12-20', 360, 295, 295
                    , 356, 295, 356, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 356, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+356
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+356
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+356
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 295, 295
                    , 356, 295, 356, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 356, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+356
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+356
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+356
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 14:32:30' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '1', '1', '150379', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-20 14:32:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35812;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','R3320', '150379', '1', '16236', '1', '200', '200', '0', '', '1', '2024-12-20 14:32:30', '16236', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35812-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 73, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549402;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16236, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 73, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+73
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 73, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+73
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '75', storedetaildate = '2024-12-20 14:32:30' WHERE storedetailid = '16235';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16236', '1', '1', '1', '150379', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-20 14:32:30','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07044', '150379', '5', '16023', '1', '200', '200', '0', '', '1', '2024-12-20 14:32:30', '16023', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549403;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16023, '2024-12-20', 200, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-5', userid = '75', storedetaildate = '2024-12-20 14:32:30' WHERE storedetailid = '16022';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16023', '1', '1', '1', '150379', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-4', '-5', '75', '2024-12-20 14:32:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36358;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06603', '150379', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-20 14:32:30', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36358-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 226.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 226.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 227, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549404;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15038, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '48', userid = '75', storedetaildate = '2024-12-20 14:32:30' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '150379', 'اضافة فاتورة مبيعات', 'sellbillController.php', '49', '48', '75', '2024-12-20 14:32:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 36355;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','H1522', '150379', '14', '15967', '3', '360', '1080', '0', '', '1', '2024-12-20 14:32:30', '15967', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36355-3,','1','1','0','0','360','1080','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 295.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 295.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 549405;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15967, '2024-12-20', 1080, 885, 885
                    , 885, 885, 885, 885
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 885, 885, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1080, sellCostBuyPrice =sellCostBuyPrice+885
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+885, sellCostMeanBuyPrice = sellCostMeanBuyPrice+885
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+885, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+885
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+885
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+885
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+885
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1080, 885, 885
                    , 885, 885, 885, 885
                    , 0, 0, 0, 0
                    , 0, 0, 0, 885, 885, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1080, sellCostBuyPrice =sellCostBuyPrice+885
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+885, sellCostMeanBuyPrice = sellCostMeanBuyPrice+885
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+885, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+885
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+885
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+885
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+885
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '31', userid = '75', storedetaildate = '2024-12-20 14:32:30' WHERE storedetailid = '15966';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15967', '1', '3', '1', '150379', 'اضافة فاتورة مبيعات', 'sellbillController.php', '34', '31', '75', '2024-12-20 14:32:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36020;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('430','07165', '150379', '5', '16343', '1', '490', '490', '0', '', '1', '2024-12-20 14:32:30', '16343', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36020-1,','1','1','0','0','490','490','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 428.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 428.00
        , lastbuyprice_withTax = 430, meanbuyprice_withTax = 426, lastbuyprice_withDiscountAndTax = 430
                where sellbilldetailid = 549406;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16343, '2024-12-20', 490, 430, 430
                    , 428, 430, 428, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 430, 426, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+428
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+428
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+430
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+430
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+426
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 490, 430, 430
                    , 428, 430, 428, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0, 430, 426, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+428
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+428
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+430
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+430
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+426
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '75', storedetaildate = '2024-12-20 14:32:30' WHERE storedetailid = '16342';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16343', '1', '1', '1', '150379', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-20 14:32:30','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150379', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:32:30', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150379', '17', '10291', '1', '32', '32', '0', '', '1', '2024-12-20 14:32:30', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','32','32','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 81 where clientid = 1207;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 3172, 2540, 2540
                    , 2600, 2540, 2600, 2550.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2540, 2527, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3172, sellCostBuyPrice =sellCostBuyPrice+2540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2550.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2540
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2527
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1207, '2024-12-20', 3172, 2540, 2540
                    , 2600, 2540, 2600, 2550.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2540, 2527, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3172, sellCostBuyPrice =sellCostBuyPrice+2540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2550.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2540
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2527
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3172, 2540, 2540
                    , 2600, 2540, 2600, 2550.95, 2540, 2527)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3172, netSellCostBuyPrice = netSellCostBuyPrice+2540
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2540
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2600
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2540
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2600
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2550.95
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2540
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2527;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676561b402da8 and sellbillId = 150379 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:02:31";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:32:31", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:32:31', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:03:05";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:33:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:33:05', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676563c0b971f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:32:00', '0676563c0b971f', '1', '0.00', '0', '0', '1', '470.00', '470', '470', '0', '1', '2024-12-20 14:33:05', '', '104', '0', 'نقدي', '1', '0', '3', '54', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','470','0','','0','0','470','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150380', '0', '2024-12-20 14:33:05', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '470', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:32:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36373;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('400','R3341', '150380', '1', '16440', '1', '470', '470', '0', '', '1', '2024-12-20 14:33:05', '16440', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36373-1,','1','1','0','0','470','470','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549409;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16440, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '46', userid = '104', storedetaildate = '2024-12-20 14:33:05' WHERE storedetailid = '16439';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16440', '1', '1', '1', '150380', 'اضافة فاتورة مبيعات', 'sellbillController.php', '47', '46', '104', '2024-12-20 14:33:05','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20273',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('19803','470', '0', '1', 'اضافة فاتورة مبيعات', '150380', '20273', '2024-12-20 14:33:05', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 54 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 470, 400, 400
                    , 400, 400, 400, 400, 400, 400)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+470, netSellCostBuyPrice = netSellCostBuyPrice+400
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+400
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+400
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+400
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+400
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+400
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+400
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+400;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676563c0b971f and sellbillId = 150380 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:03:06";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:33:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:33:06', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:04:11";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:34:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:34:11', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765640288e95
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:33:06', '06765640288e95', '1', '0.00', '0', '0', '1', '420.00', '420', '420', '0', '1', '2024-12-20 14:34:11', '', '104', '0', 'نقدي', '1', '0', '3', '21', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','420','0','','0','0','420','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150381', '0', '2024-12-20 14:34:11', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '420', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:33:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35426;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('360','06984', '150381', '5', '15945', '1', '420', '420', '0', '', '1', '2024-12-20 14:34:12', '15945', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35426-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549410;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15945, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '104', storedetaildate = '2024-12-20 14:34:12' WHERE storedetailid = '15944';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15945', '1', '1', '1', '150381', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-20 14:34:12','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20693',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('20273','420', '0', '1', 'اضافة فاتورة مبيعات', '150381', '20693', '2024-12-20 14:34:12', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 21 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 420, 360, 360
                    , 360, 360, 360, 360, 360, 360)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+420, netSellCostBuyPrice = netSellCostBuyPrice+360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+360
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+360
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+360
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+360
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+360;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765640288e95 and sellbillId = 150381 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:04:12";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:34:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:34:12', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:04:20";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:34:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 14:34:20', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=add');
BEGIN;
INSERT INTO transfermoney (saveidfrom, saveidto, transfermoneyvalue, transfermoneydate, userid, conditions, dailyentryid , comment,currencyId,conversionFactor,conversionFactorFrom,conversionFactorTo,transfermoneyvalueInCurrency) VALUES ('1','2', '1333', '2024-12-20', '104', '0', '0','','1','1','0','0','1333');
UPDATE save SET  savecurrentvalue = '19360',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('20693.00','1333', '1', '1', 'تحويل امول الى الخزنة  [ فودافون كاش ] ', '3535', '19360', '2024-12-20 14:34:20', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '93014.5',  userid = '104' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('91681.50','1333', '0', '2', 'تحويل امول من الخزنة  [ نقدي ] ', '3535', '93014.5', '2024-12-20 14:34:20', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '2', transfermoneyvalue = '1333.00', transfermoneydate = '2024-12-20', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='1333' WHERE transfermoneyid = '3535';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:04:21";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:34:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 14:34:21', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:04:22";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:34:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:34:22', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:04:39";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:34:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:34:39', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'بيدق', '', '10', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '19350',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('19360.00','10', '1', '1', 'إضافة مصروف', '25906', '19350', '2024-12-20 14:34:39', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'بيدق', expensesdetails = '', expensesValue = '10.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25906';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:04:40";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:34:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:34:40', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:04:41";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:34:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:34:42', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:04:47";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:34:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:34:47', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:05:16";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:35:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:35:16', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:05:16";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:35:16", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:35:16', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676563ad79819
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2713,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:31:41', '0676563ad79819', '2713', '-20.00', '1303', '0', '1', '1323.00', '1323', '0', '1323', '1', '2024-12-20 14:35:16', '', '101', '0', 'بسنت شبانة p1', '2', '1', '3', '82', 'بسنت شبانة p1', '5' ,'0','','','','','-1','0','0','0','0','0','1323','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1303', userid = '101' WHERE clientid = '2713';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2713','-20.00','1323','0','اضافة فاتورة مبيعات','150382', '1303', '2024-12-20 14:35:16', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1323', '0', null, '0', null, null,'', '0','1','1','1323','1','2024-12-20 14:31:41','0','0');
UPDATE client SET  inUse = 0 where clientid = 2713;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36191;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('365','H1651', '150382', '14', '16406', '1', '450', '450', '0', '', '1', '2024-12-20 14:35:17', '16406', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36191-1,','1','1','0','0','450','450','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 365.00 , meanbuyprice = 365.00, lastbuyprice_withDiscount = 365.00, meanbuyprice_withDiscount = 365.00
        , lastbuyprice_withTax = 365, meanbuyprice_withTax = 365, lastbuyprice_withDiscountAndTax = 365
                where sellbilldetailid = 549411;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16406, '2024-12-20', 450, 365, 365
                    , 365, 365, 365, 365
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 365, 365, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+365
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+365, sellCostMeanBuyPrice = sellCostMeanBuyPrice+365
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+365, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+365
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+365
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+365
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+365
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 450, 365, 365
                    , 365, 365, 365, 365
                    , 0, 0, 0, 0
                    , 0, 0, 0, 365, 365, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+365
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+365, sellCostMeanBuyPrice = sellCostMeanBuyPrice+365
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+365, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+365
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+365
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+365
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+365
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '17', userid = '101', storedetaildate = '2024-12-20 14:35:17' WHERE storedetailid = '16405';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16406', '1', '1', '1', '150382', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '101', '2024-12-20 14:35:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36350;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('380','H1496', '150382', '14', '15942', '1', '470', '470', '0', '', '1', '2024-12-20 14:35:17', '15942', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36350-1,','1','1','0','0','470','470','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 380.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 380.00
        , lastbuyprice_withTax = 380, meanbuyprice_withTax = 380, lastbuyprice_withDiscountAndTax = 380
                where sellbilldetailid = 549412;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15942, '2024-12-20', 470, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 380, 380, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+380
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 380, 380, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+380
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-20 14:35:17' WHERE storedetailid = '15941';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15942', '1', '1', '1', '150382', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '101', '2024-12-20 14:35:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36168;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('315','R3334', '150382', '1', '16400', '1', '370', '370', '0', '', '1', '2024-12-20 14:35:17', '16400', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36168-1,','1','1','0','0','370','370','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 315.00 , meanbuyprice = 315.00, lastbuyprice_withDiscount = 315.00, meanbuyprice_withDiscount = 315.00
        , lastbuyprice_withTax = 315, meanbuyprice_withTax = 315, lastbuyprice_withDiscountAndTax = 315
                where sellbilldetailid = 549413;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16400, '2024-12-20', 370, 315, 315
                    , 315, 315, 315, 315
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 315, 315, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+315
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+315, sellCostMeanBuyPrice = sellCostMeanBuyPrice+315
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+315, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+315
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+315
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+315
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+315
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 370, 315, 315
                    , 315, 315, 315, 315
                    , 0, 0, 0, 0
                    , 0, 0, 0, 315, 315, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+315
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+315, sellCostMeanBuyPrice = sellCostMeanBuyPrice+315
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+315, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+315
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+315
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+315
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+315
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '101', storedetaildate = '2024-12-20 14:35:17' WHERE storedetailid = '16399';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16400', '1', '1', '1', '150382', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '101', '2024-12-20 14:35:17','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150382', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:35:17', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150382', '17', '10291', '1', '13', '13', '0', '', '1', '2024-12-20 14:35:17', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','13','13','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 82 where clientid = 2713;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1323, 1060, 1060
                    , 1060, 1060, 1060, 1060
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1060, 1060, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1323, sellCostBuyPrice =sellCostBuyPrice+1060
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1060, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1060
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1060, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1060
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1060
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1060
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1060
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2713, '2024-12-20', 1323, 1060, 1060
                    , 1060, 1060, 1060, 1060
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1060, 1060, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1323, sellCostBuyPrice =sellCostBuyPrice+1060
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1060, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1060
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1060, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1060
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1060
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1060
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1060
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1323, 1060, 1060
                    , 1060, 1060, 1060, 1060, 1060, 1060)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1323, netSellCostBuyPrice = netSellCostBuyPrice+1060
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1060
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1060
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1060
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1060
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1060
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1060
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1060;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676563ad79819 and sellbillId = 150382 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:05:18";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:35:18", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:35:18', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:06:37";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:36:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:36:37', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676564847e540
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 14:35:16', '0676564847e540', '1', '0.00', '0', '0', '1', '845', '845', '-845', '0', '1', '2024-12-20 14:36:37', '', '104', '0', 'نقدي','1', '0', '5', '5', 'نقدي', '2', '0', '', '','','','-1','0','0','0','','0','-845','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16847', '0', '2024-12-20 14:36:37', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '845', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:35:16','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('250.00', '06956', '16847', '5', '15862', '1', '330', '330', '0', '', '1', '0', '15862', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','330','330','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 246, lastbuyprice_withDiscountAndTax = 250
                where returnsellbilldetailid = 22036;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15862, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 330, 250, 250, 250
                    , 250, 250, 250, 0, 1, 0, 0, 250, 246)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+330, returnSellCostBuyPrice = returnSellCostBuyPrice+250, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+250
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+250, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+250
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+250
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+250
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+250
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+246
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 330, 250, 250, 250
                    , 250, 250, 250, 0, 0, 250, 246)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+330, returnSellCostBuyPrice = returnSellCostBuyPrice+250, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+250
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+250, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+250
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+250
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+250
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+250
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+246;
UPDATE storedetail SET  productquantity = '4', userid = '104', storedetaildate = '2024-12-20 14:36:37' WHERE storedetailid = '15861';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15862', '1', '1', '0', '16847', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '3', '4', '104', '2024-12-20 14:36:37','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('480.00', '07167', '16847', '5', '16349', '1', '515', '515', '0', '', '1', '0', '16349', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','515','515','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 480.00 , meanbuyprice = 478.00, lastbuyprice_withDiscount = 480.00, meanbuyprice_withDiscount = 478.00
        , lastbuyprice_withTax = 480, meanbuyprice_withTax = 478, lastbuyprice_withDiscountAndTax = 480
                where returnsellbilldetailid = 22037;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16349, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 515, 480, 480, 478
                    , 480, 478, 480, 0, 1, 0, 0, 480, 478)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+515, returnSellCostBuyPrice = returnSellCostBuyPrice+480, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+480
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+478, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+480
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+478
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+480
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+480
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+478
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 515, 480, 480, 478
                    , 480, 478, 480, 0, 0, 480, 478)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+515, returnSellCostBuyPrice = returnSellCostBuyPrice+480, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+480
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+478, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+480
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+478
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+480
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+480
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+478;
UPDATE storedetail SET  productquantity = '8', userid = '104', storedetaildate = '2024-12-20 14:36:37' WHERE storedetailid = '16348';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16349', '1', '1', '0', '16847', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '7', '8', '104', '2024-12-20 14:36:37','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '18505',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('19350','-845', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16847', '18505', '2024-12-20 14:36:37', '104',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 845, 730, 730, 728
                    , 730, 728, 730 ,0, 0, 730, 724)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+845, returnSellCostBuyPrice = returnSellCostBuyPrice+730, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+730
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+728, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+730
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+728
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+730
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+730
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+724;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 845, 730, 730, 728
                    , 730, 728, 730 ,0, 0, 730, 724)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+845, returnSellCostBuyPrice = returnSellCostBuyPrice+730, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+730
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+728, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+730
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+728
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+730
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+730
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+724;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -845, -730, -730
                    , -728, -730, -728, -730, -730, -724)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-845, netSellCostBuyPrice = netSellCostBuyPrice+-730
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-730
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-728
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-730
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-728
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-730
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-730
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-724;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676564847e540 and sellbillId = 16847 and returnsellbillId = 16847
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:06:38";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:36:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:36:38', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:08:02";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:38:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:38:02', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676564451aa93
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:34:13', '0676564451aa93', '1', '0.00', '0', '50', '1', '600.00', '550', '550', '0', '1', '2024-12-20 14:38:02', '', '104', '0', 'نقدي', '1', '0', '3', '92', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','550','0','','0','0','550','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150383', '0', '2024-12-20 14:38:02', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '550', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:34:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36516;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('170','07336', '150383', '5', '16496', '1', '250', '250', '0', '', '1', '2024-12-20 14:38:02', '16496', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36516-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 549416;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16496, '2024-12-20', 229.16666666667, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+229.16666666667, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 229.16666666667, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+229.16666666667, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '104', storedetaildate = '2024-12-20 14:38:02' WHERE storedetailid = '16495';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16496', '1', '1', '1', '150383', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-20 14:38:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36456;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('280','07310', '150383', '5', '16468', '1', '350', '350', '0', '', '1', '2024-12-20 14:38:02', '16468', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36456-1,','1','1','0','0','350','350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 280, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 549417;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16468, '2024-12-20', 320.83333333333, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320.83333333333, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320.83333333333, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320.83333333333, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '104', storedetaildate = '2024-12-20 14:38:02' WHERE storedetailid = '16467';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16468', '1', '1', '1', '150383', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-20 14:38:02','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '19055',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('18505','550', '0', '1', 'اضافة فاتورة مبيعات', '150383', '19055', '2024-12-20 14:38:02', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 92 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 550, 450, 450
                    , 450, 450, 450, 450
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,450, 450, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+450
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+450
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 550, 450, 450
                    , 450, 450, 450, 450
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,450, 450, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+450
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+450
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 550, 450, 450
                    , 450, 450, 450, 450, 450, 450)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+550, netSellCostBuyPrice = netSellCostBuyPrice+450
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+450
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+450
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+450
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+450
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+450
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+450
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+450;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676564451aa93 and sellbillId = 150383 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:08:02";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:38:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:38:02', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:08:35";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:38:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:38:35', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:08:37";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:38:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:38:37', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:10:05";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:40:05", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:40:05', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676563df8f8dc
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6151,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:32:31', '0676563df8f8dc', '6151', '1.00', '2006', '0', '1', '2005.00', '2005', '0', '2005', '1', '2024-12-20 14:40:05', '', '75', '0', 'مروة الليثي I888', '2', '1', '3', '81', 'مروة الليثي I888', '10' ,'0','','','','','-1','0','0','0','0','0','2005','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2006', userid = '75' WHERE clientid = '6151';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6151','1.00','2005','0','اضافة فاتورة مبيعات','150384', '2006', '2024-12-20 14:40:05', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2005', '0', null, '0', null, null,'', '0','1','1','2005','1','2024-12-20 14:32:31','0','0');
UPDATE client SET  inUse = 0 where clientid = 6151;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35151;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('385','R3292', '150384', '1', '15921', '1', '450', '450', '0', '', '1', '2024-12-20 14:40:05', '15921', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35151-1,','1','1','0','0','450','450','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 385.00 , meanbuyprice = 385.00, lastbuyprice_withDiscount = 385.00, meanbuyprice_withDiscount = 385.00
        , lastbuyprice_withTax = 385, meanbuyprice_withTax = 385, lastbuyprice_withDiscountAndTax = 385
                where sellbilldetailid = 549418;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15921, '2024-12-20', 450, 385, 385
                    , 385, 385, 385, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 385, 385, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+385
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 450, 385, 385
                    , 385, 385, 385, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 385, 385, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+385
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 14:40:05' WHERE storedetailid = '15920';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15921', '1', '1', '1', '150384', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 14:40:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35728;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('190','07067', '150384', '5', '16076', '1', '250', '250', '0', '', '1', '2024-12-20 14:40:05', '16076', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35728-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 190, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 549419;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16076, '2024-12-20', 250, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+190
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 250, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+190
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '75', storedetaildate = '2024-12-20 14:40:05' WHERE storedetailid = '16075';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16076', '1', '1', '1', '150384', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-20 14:40:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30821;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('215','R2790', '150384', '1', '13875', '1', '175', '175', '0', '', '1', '2024-12-20 14:40:05', '13875', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30821-1,','1','1','0','0','175','175','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 215.00 , meanbuyprice = 215.00, lastbuyprice_withDiscount = 215.00, meanbuyprice_withDiscount = 215.00
        
                where sellbilldetailid = 549420;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13875, '2024-12-20', 175, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+175, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 175, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+175, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '75', storedetaildate = '2024-12-20 14:40:05' WHERE storedetailid = '13874';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13875', '1', '1', '1', '150384', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-20 14:40:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35788;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('330','07119', '150384', '5', '16122', '1', '380', '380', '0', '', '1', '2024-12-20 14:40:05', '16122', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35788-1,','1','1','0','0','380','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
        , lastbuyprice_withTax = 330, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 330
                where sellbilldetailid = 549421;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16122, '2024-12-20', 380, 330, 330
                    , 330, 330, 330, 325
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 330, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+325
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 380, 330, 330
                    , 330, 330, 330, 325
                    , 0, 0, 0, 0
                    , 0, 0, 0, 330, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+325
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '75', storedetaildate = '2024-12-20 14:40:05' WHERE storedetailid = '16121';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16122', '1', '1', '1', '150384', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-20 14:40:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32056;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('330','R2929', '150384', '1', '14420', '1', '235', '235', '0', '', '1', '2024-12-20 14:40:05', '14420', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32056-1,','1','1','0','0','235','235','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
        
                where sellbilldetailid = 549422;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14420, '2024-12-20', 235, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 235, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 14:40:05' WHERE storedetailid = '14419';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14420', '1', '1', '1', '150384', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 14:40:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32322;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('220','R2966', '150384', '1', '14553', '1', '200', '200', '0', '', '1', '2024-12-20 14:40:05', '14553', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32322-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
        
                where sellbilldetailid = 549423;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14553, '2024-12-20', 200, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 14:40:05' WHERE storedetailid = '14552';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14553', '1', '1', '1', '150384', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-20 14:40:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29721;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('195','00D36', '150384', '1', '13308', '1', '125', '125', '0', '', '1', '2024-12-20 14:40:05', '13308', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29721-1,','1','1','0','0','125','125','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 195.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 195.00
        
                where sellbilldetailid = 549424;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13308, '2024-12-20', 125, 195, 195
                    , 195, 195, 195, 195
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+195
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 125, 195, 195
                    , 195, 195, 195, 195
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+195
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 14:40:05' WHERE storedetailid = '13307';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13308', '1', '1', '1', '150384', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 14:40:05','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('150','عرض 150', '150384', '18', '10355', '1', '150', '150', '0', '', '1', '2024-12-20 14:40:05', '10355', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','150','150','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        
                where sellbilldetailid = 549425;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10355, '2024-12-20', 150, 150, 150
                    , 150, 150, 150, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 150, 150, 150
                    , 150, 150, 150, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-114', userid = '75', storedetaildate = '2024-12-20 14:40:05' WHERE storedetailid = '10354';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10355', '1', '1', '1', '150384', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-113', '-114', '75', '2024-12-20 14:40:05','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150384', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:40:05', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150384', '17', '10291', '1', '20', '20', '0', '', '1', '2024-12-20 14:40:05', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 81 where clientid = 6151;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2005, 2015, 2015
                    , 2015, 2015, 2015, 1860
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,905, 898, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2005, sellCostBuyPrice =sellCostBuyPrice+2015
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2015, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2015
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2015, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2015
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1860
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+905
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+898
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6151, '2024-12-20', 2005, 2015, 2015
                    , 2015, 2015, 2015, 1860
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,905, 898, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2005, sellCostBuyPrice =sellCostBuyPrice+2015
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2015, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2015
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2015, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2015
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1860
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+905
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+898
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2005, 2015, 2015
                    , 2015, 2015, 2015, 1860, 905, 898)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2005, netSellCostBuyPrice = netSellCostBuyPrice+2015
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2015
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2015
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2015
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2015
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1860
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+905
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+898;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676563df8f8dc and sellbillId = 150384 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:10:06";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:40:06", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:40:06', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:10:31";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:40:31", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:40:31', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676564863c6be
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9659,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:35:18', '0676564863c6be', '9659', '0.00', '1929', '0', '1', '1929.00', '1929', '0', '1929', '1', '2024-12-20 14:40:31', '', '101', '0', 'مروة عبد السميع 12', '2', '1', '3', '88', 'مروة عبد السميع 12', '8' ,'0','','','','','-1','0','0','0','0','0','1929','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1929', userid = '101' WHERE clientid = '9659';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9659','0.00','1929','0','اضافة فاتورة مبيعات','150385', '1929', '2024-12-20 14:40:31', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1929', '0', null, '0', null, null,'', '0','1','1','1929','1','2024-12-20 14:35:18','0','0');
UPDATE client SET  inUse = 0 where clientid = 9659;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35691;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('165','07149', '150385', '5', '16195', '1', '220', '220', '0', '', '1', '2024-12-20 14:40:31', '16195', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35691-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549428;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16195, '2024-12-20', 220, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '101', storedetaildate = '2024-12-20 14:40:31' WHERE storedetailid = '16194';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16195', '1', '1', '1', '150385', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '101', '2024-12-20 14:40:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35538;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('535','H1577', '150385', '14', '16129', '1', '600', '600', '0', '', '1', '2024-12-20 14:40:31', '16129', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35538-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 535.00 , meanbuyprice = 535.00, lastbuyprice_withDiscount = 535.00, meanbuyprice_withDiscount = 535.00
        , lastbuyprice_withTax = 535, meanbuyprice_withTax = 535, lastbuyprice_withDiscountAndTax = 535
                where sellbilldetailid = 549429;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16129, '2024-12-20', 600, 535, 535
                    , 535, 535, 535, 535
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 535, 535, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+535
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+535, sellCostMeanBuyPrice = sellCostMeanBuyPrice+535
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+535
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+535
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+535
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+535
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 535, 535
                    , 535, 535, 535, 535
                    , 0, 0, 0, 0
                    , 0, 0, 0, 535, 535, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+535
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+535, sellCostMeanBuyPrice = sellCostMeanBuyPrice+535
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+535
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+535
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+535
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+535
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '101', storedetaildate = '2024-12-20 14:40:31' WHERE storedetailid = '16128';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16129', '1', '1', '1', '150385', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '101', '2024-12-20 14:40:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35712;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','07096', '150385', '5', '16117', '2', '280', '560', '0', '', '1', '2024-12-20 14:40:31', '16117', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35712-2,','1','1','0','0','280','560','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 235.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 229, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549430;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16117, '2024-12-20', 560, 480, 480
                    , 470, 480, 470, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 480, 458, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+560, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+470
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+470
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+455
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+458
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 560, 480, 480
                    , 470, 480, 470, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 480, 458, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+560, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+470
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+470
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+455
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+458
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '32', userid = '101', storedetaildate = '2024-12-20 14:40:31' WHERE storedetailid = '16116';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16117', '1', '2', '1', '150385', 'اضافة فاتورة مبيعات', 'sellbillController.php', '34', '32', '101', '2024-12-20 14:40:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35859;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07184', '150385', '5', '16266', '1', '210', '210', '0', '', '1', '2024-12-20 14:40:32', '16266', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35859-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549431;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16266, '2024-12-20', 210, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 14:40:32' WHERE storedetailid = '16265';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16266', '1', '1', '1', '150385', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '101', '2024-12-20 14:40:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35825;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','07175', '150385', '5', '16241', '1', '300', '300', '0', '', '1', '2024-12-20 14:40:32', '16241', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35825-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549432;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16241, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '101', storedetaildate = '2024-12-20 14:40:32' WHERE storedetailid = '16240';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16241', '1', '1', '1', '150385', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '101', '2024-12-20 14:40:32','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150385', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:40:32', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150385', '17', '10291', '1', '19', '19', '0', '', '1', '2024-12-20 14:40:32', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','19','19','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 88 where clientid = 9659;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1929, 1575, 1575
                    , 1565, 1575, 1565, 1550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1575, 1553, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1929, sellCostBuyPrice =sellCostBuyPrice+1575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1565
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1565
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1553
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9659, '2024-12-20', 1929, 1575, 1575
                    , 1565, 1575, 1565, 1550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1575, 1553, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1929, sellCostBuyPrice =sellCostBuyPrice+1575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1565
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1565
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1553
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1929, 1575, 1575
                    , 1565, 1575, 1565, 1550, 1575, 1553)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1929, netSellCostBuyPrice = netSellCostBuyPrice+1575
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1575
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1565
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1575
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1565
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1550
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1575
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1553;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676564863c6be and sellbillId = 150385 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:10:32";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:40:32", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:40:32', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:11:47";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:41:47", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:41:47', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:11:58";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:41:58", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:41:58', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765654bda80a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 14:38:35', '06765654bda80a', '1', '0.00', '0', '10', '1', '210', '200', '-200', '0', '1', '2024-12-20 14:41:59', '', '104', '0', 'نقدي','1', '0', '5', '21', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-200','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16848', '0', '2024-12-20 14:41:59', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:38:35','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('155.00', 'R3112', '16848', '1', '15028', '1', '210', '210', '0', '', '1', '0', '15028', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','210','210','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        
                where returnsellbilldetailid = 22038;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15028, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 220, 155, 155, 155
                    , 155, 155, 155, 0, 1, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+220, returnSellCostBuyPrice = returnSellCostBuyPrice+155, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+155
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+155, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+155
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+155
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+155
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 220, 155, 155, 155
                    , 155, 155, 155, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+220, returnSellCostBuyPrice = returnSellCostBuyPrice+155, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+155
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+155, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+155
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+155
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+155
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '104', storedetaildate = '2024-12-20 14:41:59' WHERE storedetailid = '15027';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15028', '1', '1', '0', '16848', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '9', '10', '104', '2024-12-20 14:41:59','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '18855',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('19055','-200', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16848', '18855', '2024-12-20 14:41:59', '104',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 21 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 155, 155, 155
                    , 155, 155, 155 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+200, returnSellCostBuyPrice = returnSellCostBuyPrice+155, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+155
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+155, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+155
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+155
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+155
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 155, 155, 155
                    , 155, 155, 155 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+200, returnSellCostBuyPrice = returnSellCostBuyPrice+155, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+155
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+155, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+155
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+155
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+155
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -200, -155, -155
                    , -155, -155, -155, -155, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-200, netSellCostBuyPrice = netSellCostBuyPrice+-155
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-155
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-155
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-155
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-155
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-155
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765654bda80a and sellbillId = 16848 and returnsellbillId = 16848
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:11:59";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:41:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:41:59', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:12:06";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:42:06", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:42:06', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:12:09";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:42:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:42:10', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765654de0291
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:38:37', '06765654de0291', '1', '0.00', '0', '70', '1', '2005.00', '1935', '1935', '0', '1', '2024-12-20 14:42:10', '', '104', '0', 'نقدي', '1', '0', '3', '21', 'نقدي', '7' ,'0','','','','','-1','0','0','0','0','0','1935','0','','0','0','1935','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150386', '0', '2024-12-20 14:42:10', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1935', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:38:37','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36335;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('180','H1658', '150386', '14', '16424', '1', '250', '250', '0', '', '1', '2024-12-20 14:42:10', '16424', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36335-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
        , lastbuyprice_withTax = 180, meanbuyprice_withTax = 180, lastbuyprice_withDiscountAndTax = 180
                where sellbilldetailid = 549435;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16424, '2024-12-20', 241.27182044888, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+241.27182044888, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+180
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 241.27182044888, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+241.27182044888, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+180
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '104', storedetaildate = '2024-12-20 14:42:10' WHERE storedetailid = '16423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16424', '1', '1', '1', '150386', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '104', '2024-12-20 14:42:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36336;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','23664', '150386', '5', '15673', '1', '360', '360', '0', '', '1', '2024-12-20 14:42:10', '15673', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36336-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 295.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 295.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 549436;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15673, '2024-12-20', 347.43142144638, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+347.43142144638, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 347.43142144638, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+347.43142144638, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '31', userid = '104', storedetaildate = '2024-12-20 14:42:10' WHERE storedetailid = '15672';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15673', '1', '1', '1', '150386', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32', '31', '104', '2024-12-20 14:42:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35839;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','07185', '150386', '5', '16250', '1', '300', '300', '0', '', '1', '2024-12-20 14:42:10', '16250', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35839-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549437;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16250, '2024-12-20', 289.52618453865, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+289.52618453865, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 289.52618453865, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+289.52618453865, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '104', storedetaildate = '2024-12-20 14:42:10' WHERE storedetailid = '16249';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16250', '1', '1', '1', '150386', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-20 14:42:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35397;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('215','0K789', '150386', '7', '15760', '1', '275', '275', '0', '', '1', '2024-12-20 14:42:10', '15760', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35397-1,','1','1','0','0','275','275','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 215.00 , meanbuyprice = 215.00, lastbuyprice_withDiscount = 215.00, meanbuyprice_withDiscount = 215.00
        , lastbuyprice_withTax = 215, meanbuyprice_withTax = 215, lastbuyprice_withDiscountAndTax = 215
                where sellbilldetailid = 549438;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15760, '2024-12-20', 265.39900249377, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 215, 215, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+265.39900249377, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+215
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 265.39900249377, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 215, 215, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+265.39900249377, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+215
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '22', userid = '104', storedetaildate = '2024-12-20 14:42:10' WHERE storedetailid = '15759';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15760', '1', '1', '1', '150386', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '104', '2024-12-20 14:42:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35654;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','R3314', '150386', '1', '16182', '1', '300', '300', '0', '', '1', '2024-12-20 14:42:10', '16182', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35654-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 549439;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16182, '2024-12-20', 289.52618453865, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+289.52618453865, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 289.52618453865, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+289.52618453865, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-20 14:42:10' WHERE storedetailid = '16181';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16182', '1', '1', '1', '150386', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-20 14:42:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36358;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06603', '150386', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-20 14:42:10', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36358-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 226.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 226.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 227, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549440;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15038, '2024-12-20', 279.8753117207, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+279.8753117207, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 279.8753117207, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+279.8753117207, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '47', userid = '104', storedetaildate = '2024-12-20 14:42:10' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '150386', 'اضافة فاتورة مبيعات', 'sellbillController.php', '48', '47', '104', '2024-12-20 14:42:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35713;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('175','12339', '150386', '5', '16211', '1', '230', '230', '0', '', '1', '2024-12-20 14:42:10', '16211', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35713-1,','1','1','0','0','230','230','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 175.00 , meanbuyprice = 175.00, lastbuyprice_withDiscount = 175.00, meanbuyprice_withDiscount = 175.00
        , lastbuyprice_withTax = 175, meanbuyprice_withTax = 175, lastbuyprice_withDiscountAndTax = 175
                where sellbilldetailid = 549441;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16211, '2024-12-20', 221.97007481297, 175, 175
                    , 175, 175, 175, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 175, 175, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+221.97007481297, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+175
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+175
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+175
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+175
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+175
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 221.97007481297, 175, 175
                    , 175, 175, 175, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 175, 175, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+221.97007481297, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+175
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+175
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+175
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+175
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+175
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-20 14:42:10' WHERE storedetailid = '16210';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16211', '1', '1', '1', '150386', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-20 14:42:10','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20790',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('18855','1935', '0', '1', 'اضافة فاتورة مبيعات', '150386', '20790', '2024-12-20 14:42:10', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 21 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1935, 1580, 1580
                    , 1581, 1580, 1581, 1590.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1580, 1582, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1935, sellCostBuyPrice =sellCostBuyPrice+1580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1581
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1581
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1590.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1582
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1935, 1580, 1580
                    , 1581, 1580, 1581, 1590.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1580, 1582, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1935, sellCostBuyPrice =sellCostBuyPrice+1580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1581
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1581
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1590.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1582
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1935, 1580, 1580
                    , 1581, 1580, 1581, 1590.95, 1580, 1582)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1935, netSellCostBuyPrice = netSellCostBuyPrice+1580
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1580
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1581
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1580
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1581
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1590.95
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1580
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1582;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765654de0291 and sellbillId = 150386 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:12:11";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:42:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:42:11', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:12:23";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:42:23", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:42:23', '101', 'editsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150373');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:13:14";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:43:14", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:43:14', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676565a6c9a39
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9493,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:40:06', '0676565a6c9a39', '9493', '0.00', '242', '0', '1', '242.00', '242', '0', '242', '1', '2024-12-20 14:43:14', '', '75', '0', 'د/ اسراء', '2', '1', '3', '91', 'د/ اسراء', '3' ,'0','','','','','-1','0','0','0','0','0','242','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '242', userid = '75' WHERE clientid = '9493';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9493','0.00','242','0','اضافة فاتورة مبيعات','150387', '242', '2024-12-20 14:43:14', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '242', '0', null, '0', null, null,'', '0','1','1','242','1','2024-12-20 14:40:06','0','0');
UPDATE client SET  inUse = 0 where clientid = 9493;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32994;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('235','06523', '150387', '5', '14892', '1', '220', '220', '0', '', '1', '2024-12-20 14:43:14', '14892', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32994-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 235.00
        
                where sellbilldetailid = 549442;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14892, '2024-12-20', 220, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 14:43:14' WHERE storedetailid = '14891';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14892', '1', '1', '1', '150387', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 14:43:14','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150387', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:43:14', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150387', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-20 14:43:14', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','2','2','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 91 where clientid = 9493;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 242, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+242, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9493, '2024-12-20', 242, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+242, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 242, 235, 235
                    , 235, 235, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+242, netSellCostBuyPrice = netSellCostBuyPrice+235
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+235
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+235
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+235
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+235
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+235
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676565a6c9a39 and sellbillId = 150387 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:13:15";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:43:15", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:43:15', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:13:31";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:43:31", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:43:31', '101', 'update', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 150373 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 150373 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150373;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 14:43:31', userid = '101',delbyuserid = '101', conditions = '1'  WHERE sellbillid = '150373';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36175;
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 265, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 549363;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16401, '2024-12-20', 320, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-320, sellCostBuyPrice =sellCostBuyPrice-265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-265, sellCostMeanBuyPrice = sellCostMeanBuyPrice-265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-265
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-320, sellCostBuyPrice =sellCostBuyPrice-265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-265, sellCostMeanBuyPrice = sellCostMeanBuyPrice-265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-265
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '13', userid = '101', storedetaildate = '2024-12-20 14:43:31' WHERE storedetailid = '16400';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16401', '1', '1', '0', '150373', 'تعديل فاتورة مبيعات', 'sellbillController.php', '12', '13', '101', '2024-12-20 14:15:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36346;
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549364;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16223, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-470, sellCostBuyPrice =sellCostBuyPrice-400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-400, sellCostMeanBuyPrice = sellCostMeanBuyPrice-400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-400
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-470, sellCostBuyPrice =sellCostBuyPrice-400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-400, sellCostMeanBuyPrice = sellCostMeanBuyPrice-400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-400
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '12', userid = '101', storedetaildate = '2024-12-20 14:43:31' WHERE storedetailid = '16222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16223', '1', '1', '0', '150373', 'تعديل فاتورة مبيعات', 'sellbillController.php', '11', '12', '101', '2024-12-20 14:15:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36459;
UPDATE sellbilldetail SET  lastbuyprice = 525.00 , meanbuyprice = 525.00, lastbuyprice_withDiscount = 525.00, meanbuyprice_withDiscount = 525.00
        , lastbuyprice_withTax = 525, meanbuyprice_withTax = 525, lastbuyprice_withDiscountAndTax = 525
                where sellbilldetailid = 549365;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16470, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-610, sellCostBuyPrice =sellCostBuyPrice-525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-525, sellCostMeanBuyPrice = sellCostMeanBuyPrice-525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-525
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-610, sellCostBuyPrice =sellCostBuyPrice-525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-525, sellCostMeanBuyPrice = sellCostMeanBuyPrice-525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-525
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 14:43:31' WHERE storedetailid = '16469';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16470', '1', '1', '0', '150373', 'تعديل فاتورة مبيعات', 'sellbillController.php', '1', '2', '101', '2024-12-20 14:15:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36146;
UPDATE sellbilldetail SET  lastbuyprice = 585.00 , meanbuyprice = 585.00, lastbuyprice_withDiscount = 585.00, meanbuyprice_withDiscount = 585.00
        , lastbuyprice_withTax = 585, meanbuyprice_withTax = 585, lastbuyprice_withDiscountAndTax = 585
                where sellbilldetailid = 549366;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16388, '2024-12-20', 700, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-700, sellCostBuyPrice =sellCostBuyPrice-585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-585, sellCostMeanBuyPrice = sellCostMeanBuyPrice-585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-585
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-585
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 700, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0, 585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-700, sellCostBuyPrice =sellCostBuyPrice-585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-585, sellCostMeanBuyPrice = sellCostMeanBuyPrice-585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-585
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-585
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '17', userid = '101', storedetaildate = '2024-12-20 14:43:31' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '1', '0', '150373', 'تعديل فاتورة مبيعات', 'sellbillController.php', '16', '17', '101', '2024-12-20 14:15:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36340;
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549369;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16426, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-360, sellCostMeanBuyPrice = sellCostMeanBuyPrice-360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-360
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-360, sellCostMeanBuyPrice = sellCostMeanBuyPrice-360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-360
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '12', userid = '101', storedetaildate = '2024-12-20 14:43:31' WHERE storedetailid = '16425';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16426', '1', '1', '0', '150373', 'تعديل فاتورة مبيعات', 'sellbillController.php', '11', '12', '101', '2024-12-20 14:15:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36162;
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 125, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 549370;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16397, '2024-12-20', 310, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 250, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-310, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-125
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 310, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-310, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-125
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '5', userid = '101', storedetaildate = '2024-12-20 14:43:31' WHERE storedetailid = '16396';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16397', '1', '1', '0', '150373', 'تعديل فاتورة مبيعات', 'sellbillController.php', '4', '5', '101', '2024-12-20 14:15:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36365;
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549371;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16434, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-200, sellCostBuyPrice =sellCostBuyPrice-145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-145, sellCostMeanBuyPrice = sellCostMeanBuyPrice-145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-145
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-200, sellCostBuyPrice =sellCostBuyPrice-145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-145, sellCostMeanBuyPrice = sellCostMeanBuyPrice-145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-145
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 14:43:31' WHERE storedetailid = '16433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16434', '1', '1', '0', '150373', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '101', '2024-12-20 14:15:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35873;
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 549372;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15995, '2024-12-20', 480, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-480, sellCostBuyPrice =sellCostBuyPrice-420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-420, sellCostMeanBuyPrice = sellCostMeanBuyPrice-420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-420
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 480, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-480, sellCostBuyPrice =sellCostBuyPrice-420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-420, sellCostMeanBuyPrice = sellCostMeanBuyPrice-420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-420
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '53', userid = '101', storedetaildate = '2024-12-20 14:43:31' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '0', '150373', 'تعديل فاتورة مبيعات', 'sellbillController.php', '52', '53', '101', '2024-12-20 14:15:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36418;
UPDATE sellbilldetail SET  lastbuyprice = 340.00 , meanbuyprice = 340.00, lastbuyprice_withDiscount = 340.00, meanbuyprice_withDiscount = 340.00
        , lastbuyprice_withTax = 340, meanbuyprice_withTax = 340, lastbuyprice_withDiscountAndTax = 340
                where sellbilldetailid = 549373;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16404, '2024-12-20', 420, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-340, sellCostMeanBuyPrice = sellCostMeanBuyPrice-340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-340
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-340, sellCostMeanBuyPrice = sellCostMeanBuyPrice-340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-340
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '16', userid = '101', storedetaildate = '2024-12-20 14:43:31' WHERE storedetailid = '16403';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16404', '1', '1', '0', '150373', 'تعديل فاتورة مبيعات', 'sellbillController.php', '15', '16', '101', '2024-12-20 14:15:51','0','0');
CALL clientInUse(2258,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '101' WHERE clientid = '2258';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2258','3990.00','3990.00','1','تعديل فاتورة مبيعات','150373', '0', '2024-12-20 14:15:51', '101', 'sellbillController.php', 'تعديل فاتورة مبيعات', '3990', '0', null, '0', null, null,'', '0','1','1','3990','1','2024-12-20 14:15:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 2258;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 3990, 3290, 3290
                    , 3290, 3290, 3290, 3290
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3290, 3165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-3990, sellCostBuyPrice =sellCostBuyPrice-3290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-3290, sellCostMeanBuyPrice = sellCostMeanBuyPrice-3290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-3290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-3290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-3290
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-3290
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-3165
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2258, '2024-12-20', 3990, 3290, 3290
                    , 3290, 3290, 3290, 3290
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3290, 3165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-3990, sellCostBuyPrice =sellCostBuyPrice-3290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-3290, sellCostMeanBuyPrice = sellCostMeanBuyPrice-3290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-3290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-3290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-3290
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-3290
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-3165
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3990, 3290, 3290
                    , 3290, 3290, 3290, 3290, 3290, 3165)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-3990, netSellCostBuyPrice = netSellCostBuyPrice-3290
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-3290
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-3290
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-3290
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-3290
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-3290
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-3290
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-3165;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 150373 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 150373 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(2258,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:15:51', '067655ff7a30f5', '2258', '0.00', '4330', '150', '1', '4480', '4330', '0', '4330', '1', '2024-12-20 14:15:51', '', '101', '0', 'ماجي محمد W3', '2', '1', '3', '79', 'ماجي محمد W3', '10', '150373', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '4330', userid = '101' WHERE clientid = '2258';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2258','0.00','4330','0','اضافة فاتورة مبيعات (معدله)','150388', '4330', '2024-12-20 14:43:31', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '4330', '0', null, '0', null, null,'', '0','1','1','3990','1','2024-12-20 14:15:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 2258;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36175;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('265','10747', '150388', '5', '16401', '1', '320', '320', '0', '', '1', '2024-12-20 14:43:31', '16401', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36175-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 265, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 549445;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16401, '2024-12-20', 309.28571428571, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+309.28571428571, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 309.28571428571, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+309.28571428571, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '101', storedetaildate = '2024-12-20 14:43:31' WHERE storedetailid = '16400';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16401', '1', '1', '1', '150388', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '13', '12', '101', '2024-12-20 14:43:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36346;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('400','R3319', '150388', '1', '16223', '1', '470', '470', '0', '', '1', '2024-12-20 14:43:31', '16223', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36346-1,','1','1','0','0','470','470','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549446;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16223, '2024-12-20', 454.26339285714, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+454.26339285714, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 454.26339285714, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+454.26339285714, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '101', storedetaildate = '2024-12-20 14:43:31' WHERE storedetailid = '16222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16223', '1', '1', '1', '150388', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '12', '11', '101', '2024-12-20 14:43:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36459;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('525','H1666', '150388', '14', '16470', '1', '610', '610', '0', '', '1', '2024-12-20 14:43:32', '16470', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36459-1,','1','1','0','0','610','610','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 525.00 , meanbuyprice = 525.00, lastbuyprice_withDiscount = 525.00, meanbuyprice_withDiscount = 525.00
        , lastbuyprice_withTax = 525, meanbuyprice_withTax = 525, lastbuyprice_withDiscountAndTax = 525
                where sellbilldetailid = 549447;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16470, '2024-12-20', 589.57589285714, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+589.57589285714, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 589.57589285714, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+589.57589285714, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 14:43:32' WHERE storedetailid = '16469';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16470', '1', '1', '1', '150388', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '2', '1', '101', '2024-12-20 14:43:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36146;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('585','H1644', '150388', '14', '16388', '1', '700', '700', '0', '', '1', '2024-12-20 14:43:32', '16388', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36146-1,','1','1','0','0','700','700','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 585.00 , meanbuyprice = 585.00, lastbuyprice_withDiscount = 585.00, meanbuyprice_withDiscount = 585.00
        , lastbuyprice_withTax = 585, meanbuyprice_withTax = 585, lastbuyprice_withDiscountAndTax = 585
                where sellbilldetailid = 549448;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16388, '2024-12-20', 676.5625, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+676.5625, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+585
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+585
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 676.5625, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0, 585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+676.5625, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+585
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+585
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '16', userid = '101', storedetaildate = '2024-12-20 14:43:32' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '1', '1', '150388', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '17', '16', '101', '2024-12-20 14:43:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36340;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('360','07290', '150388', '5', '16426', '1', '420', '420', '0', '', '1', '2024-12-20 14:43:32', '16426', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36340-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549449;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16426, '2024-12-20', 405.9375, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+405.9375, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 405.9375, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+405.9375, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '101', storedetaildate = '2024-12-20 14:43:32' WHERE storedetailid = '16425';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16426', '1', '1', '1', '150388', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '12', '11', '101', '2024-12-20 14:43:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36162;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','07281', '150388', '5', '16397', '1', '310', '310', '0', '', '1', '2024-12-20 14:43:32', '16397', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36162-1,','1','1','0','0','310','310','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 125, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 549450;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16397, '2024-12-20', 299.62053571429, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+299.62053571429, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+125
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 299.62053571429, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+299.62053571429, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+125
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-20 14:43:32' WHERE storedetailid = '16396';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16397', '1', '1', '1', '150388', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '5', '4', '101', '2024-12-20 14:43:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36365;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','07293', '150388', '5', '16434', '1', '200', '200', '0', '', '1', '2024-12-20 14:43:32', '16434', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36365-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549451;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16434, '2024-12-20', 193.30357142857, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+193.30357142857, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 193.30357142857, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+193.30357142857, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '101', storedetaildate = '2024-12-20 14:43:32' WHERE storedetailid = '16433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16434', '1', '1', '1', '150388', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '1', '0', '101', '2024-12-20 14:43:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35873;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('420','07037', '150388', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-20 14:43:32', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35873-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 549452;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15995, '2024-12-20', 463.92857142857, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+463.92857142857, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 463.92857142857, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+463.92857142857, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '52', userid = '101', storedetaildate = '2024-12-20 14:43:32' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '150388', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '53', '52', '101', '2024-12-20 14:43:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36418;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('340','H1667', '150388', '14', '16404', '1', '420', '420', '0', '', '1', '2024-12-20 14:43:32', '16404', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36418-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 340.00 , meanbuyprice = 340.00, lastbuyprice_withDiscount = 340.00, meanbuyprice_withDiscount = 340.00
        , lastbuyprice_withTax = 340, meanbuyprice_withTax = 340, lastbuyprice_withDiscountAndTax = 340
                where sellbilldetailid = 549453;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16404, '2024-12-20', 405.9375, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+405.9375, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+340
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 405.9375, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+405.9375, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+340
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '101', storedetaildate = '2024-12-20 14:43:32' WHERE storedetailid = '16403';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16404', '1', '1', '1', '150388', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '16', '15', '101', '2024-12-20 14:43:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36184;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('455','07280', '150388', '5', '16390', '1', '550', '550', '0', '', '1', '2024-12-20 14:43:32', '16390', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36184-1,','1','1','0','0','550','550','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 455.00 , meanbuyprice = 455.00, lastbuyprice_withDiscount = 455.00, meanbuyprice_withDiscount = 455.00
        , lastbuyprice_withTax = 455, meanbuyprice_withTax = 455, lastbuyprice_withDiscountAndTax = 455
                where sellbilldetailid = 549454;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16390, '2024-12-20', 531.58482142857, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+531.58482142857, sellCostBuyPrice =sellCostBuyPrice+455
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+455, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+455, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+455
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+455
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+455
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 531.58482142857, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+531.58482142857, sellCostBuyPrice =sellCostBuyPrice+455
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+455, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+455, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+455
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+455
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+455
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '101', storedetaildate = '2024-12-20 14:43:32' WHERE storedetailid = '16389';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16390', '1', '1', '1', '150388', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '10', '9', '101', '2024-12-20 14:43:32','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 4330, 3745, 3745
                    , 3745, 3745, 3745, 3745
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3745, 3620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4330, sellCostBuyPrice =sellCostBuyPrice+3745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3745
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3745
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3745
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3620
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2258, '2024-12-20', 4330, 3745, 3745
                    , 3745, 3745, 3745, 3745
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3745, 3620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4330, sellCostBuyPrice =sellCostBuyPrice+3745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3745
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3745
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3745
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3620
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 4330, 3745, 3745
                    , 3745, 3745, 3745, 3745, 3745, 3620)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+4330, netSellCostBuyPrice = netSellCostBuyPrice+3745
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3745
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+3745
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3745
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+3745
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+3745
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+3745
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+3620;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150373 and newid=150388 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:13:32";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:43:32", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:43:32', '101', 'editprint', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150388');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:13:57";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:43:57", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:43:57', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:14:36";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:44:36", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:44:36', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150376');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:14:41";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:44:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:44:41', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247882
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10484,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 14:44:41', userid = '2' WHERE clientid = '10484';
UPDATE client SET  inUse = 0 where clientid = 10484;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10484','835.00','835','1','ايصال تحصيل (( قبض من عميل ))','247882', '0', '2024-12-20 14:30:21', '2', 'clientPayedDeptController.php', '   ', '835', '0', null, '0', null, null,'', '-1','1','1','835','1','','3624','0');
UPDATE save SET  savecurrentvalue = '93849.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('93014.50','835', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247899', '93849.5', '2024-12-20 14:44:41', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '835', '835', '2024-12-20', '2', '0', '0', '2024-12-20 14:44:41','اضافة ايصال سداد للعميل ام صفون 99','1','0','0','0','247899','clientPayedDeptController.php?do=show&id=247899');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122284', '-1', '835', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '835', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122284', '11902', '835', '','0');
UPDATE accountstree SET name = 'ام صفون 99', customName = 'ام صفون 99', customNameEn = 'ام صفون 99', nameEn = 'ام صفون 99', parent = '58', accountNature = '0', theValue = '-1035', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-11-25 16:43:35' WHERE id = '11902';
UPDATE clientdebtchange SET clientid = '10484', clientdebtchangebefore = '835.000', clientdebtchangeamount = '835.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247882', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 14:30:21', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '835.00',discount='', reciptid='0', dailyentryid = '122284',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='835',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247899';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247882 -clientdebtchangeId = 247899
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:14:42";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:44:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:44:42', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:14:54";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:44:54", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:44:54', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150388');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:15:05";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:45:05", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:45:05', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150365');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:15:22";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:45:22", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:45:22', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150364');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:15:33";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:45:33", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:45:33', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150374');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:15:50";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:45:50", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:45:50', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:16:01";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:46:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:46:01', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247900
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2018,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-188' , clientdate = '2024-12-20 14:46:01', userid = '2' WHERE clientid = '2018';
UPDATE client SET  inUse = 0 where clientid = 2018;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2018','18762.00','18950','1','ايصال تحصيل (( قبض من عميل ))','247900', '-188', '2024-12-20 14:44:42', '2', 'clientPayedDeptController.php', '   ', '18950', '0', null, '0', null, null,'', '-1','1','1','18950','1','','3625','0');
UPDATE save SET  savecurrentvalue = '112799.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('93849.50','18950', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247900', '112799.5', '2024-12-20 14:46:01', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('ابانوب جمله', 'ابانوب جمله', 'ابانوب جمله', 'ابانوب جمله', '58', '0', '-188.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 14:46:01');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '18950', '18950', '2024-12-20', '2', '0', '0', '2024-12-20 14:46:01','اضافة ايصال سداد للعميل ابانوب جمله','1','0','0','0','247900','clientPayedDeptController.php?do=show&id=247900');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122285', '-1', '18950', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '18950', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122285', '12602', '18950', '','0');
UPDATE accountstree SET name = 'ابانوب جمله', customName = 'ابانوب جمله', customNameEn = 'ابانوب جمله', nameEn = 'ابانوب جمله', parent = '58', accountNature = '0', theValue = '-19138', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 14:46:01' WHERE id = '12602';
UPDATE clientdebtchange SET clientid = '2018', clientdebtchangebefore = '18762.000', clientdebtchangeamount = '18950.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247900', clientdebtchangeafter = '-188.000', clientdebtchangedate = '2024-12-20 14:44:42', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '18950.00',discount='', reciptid='0', dailyentryid = '122285',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='18950',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247900';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247900 -clientdebtchangeId = 247900
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:16:02";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:46:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:46:02', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:16:13";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:46:13", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:46:13', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150382');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:16:23";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:46:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:46:23', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247901
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8727,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 14:46:23', userid = '2' WHERE clientid = '8727';
UPDATE client SET  inUse = 0 where clientid = 8727;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8727','1640.00','1640','1','ايصال تحصيل (( قبض من عميل ))','247901', '0', '2024-12-20 14:46:02', '2', 'clientPayedDeptController.php', '   ', '1640', '0', null, '0', null, null,'', '-1','1','1','1640','1','','3626','0');
UPDATE save SET  savecurrentvalue = '114439.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('112799.50','1640', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247901', '114439.5', '2024-12-20 14:46:23', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('مارسلينو E936', 'مارسلينو E936', 'مارسلينو E936', 'مارسلينو E936', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 14:46:23');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1640', '1640', '2024-12-20', '2', '0', '0', '2024-12-20 14:46:23','اضافة ايصال سداد للعميل مارسلينو E936','1','0','0','0','247901','clientPayedDeptController.php?do=show&id=247901');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122286', '-1', '1640', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1640', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122286', '12603', '1640', '','0');
UPDATE accountstree SET name = 'مارسلينو E936', customName = 'مارسلينو E936', customNameEn = 'مارسلينو E936', nameEn = 'مارسلينو E936', parent = '58', accountNature = '0', theValue = '-1640', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 14:46:23' WHERE id = '12603';
UPDATE clientdebtchange SET clientid = '8727', clientdebtchangebefore = '1640.000', clientdebtchangeamount = '1640.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247901', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 14:46:02', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1640.00',discount='', reciptid='0', dailyentryid = '122286',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1640',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247901';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247901 -clientdebtchangeId = 247901
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:16:24";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:46:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:46:24', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:16:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:46:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:46:46', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:16:52";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:46:52", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:46:52', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:17:10";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:47:10", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:47:10', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150385');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:17:21";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:47:21", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:47:21', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150344');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:17:42";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:47:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:47:42', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247902
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10505,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '59' , clientdate = '2024-12-20 14:47:43', userid = '2' WHERE clientid = '10505';
UPDATE client SET  inUse = 0 where clientid = 10505;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10505','1909.00','1850','1','ايصال تحصيل (( قبض من عميل ))','247902', '59', '2024-12-20 14:46:24', '2', 'clientPayedDeptController.php', '   ', '1850', '0', null, '0', null, null,'', '-1','1','1','1850','1','','3627','0');
UPDATE save SET  savecurrentvalue = '116289.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('114439.50','1850', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247902', '116289.5', '2024-12-20 14:47:43', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1850', '1850', '2024-12-20', '2', '0', '0', '2024-12-20 14:47:43','اضافة ايصال سداد للعميل داليا نجيب الغردقة 43','1','0','0','0','247902','clientPayedDeptController.php?do=show&id=247902');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122287', '-1', '1850', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1850', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122287', '11968', '1850', '','0');
UPDATE accountstree SET name = 'داليا نجيب الغردقة 43', customName = 'داليا نجيب الغردقة 43', customNameEn = 'داليا نجيب الغردقة 43', nameEn = 'داليا نجيب الغردقة 43', parent = '58', accountNature = '0', theValue = '-2830', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-11-27 15:22:36' WHERE id = '11968';
UPDATE clientdebtchange SET clientid = '10505', clientdebtchangebefore = '1909.000', clientdebtchangeamount = '1850.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247902', clientdebtchangeafter = '59.000', clientdebtchangedate = '2024-12-20 14:46:24', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1850.00',discount='', reciptid='0', dailyentryid = '122287',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1850',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247902';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247902 -clientdebtchangeId = 247902
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:17:43";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:47:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:47:43', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:18:06";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:48:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:48:06', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247903
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1188,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '20' , clientdate = '2024-12-20 14:48:06', userid = '2' WHERE clientid = '1188';
UPDATE client SET  inUse = 0 where clientid = 1188;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1188','313.00','293','1','ايصال تحصيل (( قبض من عميل ))','247903', '20', '2024-12-20 14:47:44', '2', 'clientPayedDeptController.php', '   ', '293', '0', null, '0', null, null,'', '-1','1','1','293','1','','3628','0');
UPDATE save SET  savecurrentvalue = '116582.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('116289.50','293', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247903', '116582.5', '2024-12-20 14:48:06', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('محمود المنيل y57', 'محمود المنيل y57', 'محمود المنيل y57', 'محمود المنيل y57', '58', '0', '20.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 14:48:06');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '293', '293', '2024-12-20', '2', '0', '0', '2024-12-20 14:48:06','اضافة ايصال سداد للعميل محمود المنيل y57','1','0','0','0','247903','clientPayedDeptController.php?do=show&id=247903');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122288', '-1', '293', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '293', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122288', '12604', '293', '','0');
UPDATE accountstree SET name = 'محمود المنيل y57', customName = 'محمود المنيل y57', customNameEn = 'محمود المنيل y57', nameEn = 'محمود المنيل y57', parent = '58', accountNature = '0', theValue = '-273', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 14:48:06' WHERE id = '12604';
UPDATE clientdebtchange SET clientid = '1188', clientdebtchangebefore = '313.000', clientdebtchangeamount = '293.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247903', clientdebtchangeafter = '20.000', clientdebtchangedate = '2024-12-20 14:47:44', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '293.00',discount='', reciptid='0', dailyentryid = '122288',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='293',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247903';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247903 -clientdebtchangeId = 247903
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:18:07";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:48:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:48:07', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:18:33";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:48:33", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:48:33', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:18:44";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:48:44", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 14:48:44', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:18:55";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 14:48:55", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 14:48:55', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:19:16";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:49:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:49:16', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247904
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10490,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '1399' , clientdate = '2024-12-20 14:49:17', userid = '2' WHERE clientid = '10490';
UPDATE client SET  inUse = 0 where clientid = 10490;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10490','2349.00','950','1','ايصال تحصيل (( قبض من عميل ))','247904', '1399', '2024-12-20 14:48:07', '2', 'clientPayedDeptController.php', '   ', '950', '0', null, '0', null, null,'', '-1','1','1','950','1','','3629','0');
UPDATE save SET  savecurrentvalue = '117532.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('116582.50','950', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247904', '117532.5', '2024-12-20 14:49:17', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '950', '950', '2024-12-20', '2', '0', '0', '2024-12-20 14:49:17','اضافة ايصال سداد للعميل رغدة رضا 26','1','0','0','0','247904','clientPayedDeptController.php?do=show&id=247904');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122289', '-1', '950', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '950', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122289', '11920', '950', '','0');
UPDATE accountstree SET name = 'رغدة رضا 26', customName = 'رغدة رضا 26', customNameEn = 'رغدة رضا 26', nameEn = 'رغدة رضا 26', parent = '58', accountNature = '0', theValue = '-950', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-11-26 13:39:51' WHERE id = '11920';
UPDATE clientdebtchange SET clientid = '10490', clientdebtchangebefore = '2349.000', clientdebtchangeamount = '950.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247904', clientdebtchangeafter = '1399.000', clientdebtchangedate = '2024-12-20 14:48:07', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '950.00',discount='', reciptid='0', dailyentryid = '122289',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='950',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247904';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247904 -clientdebtchangeId = 247904
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:19:17";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:49:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:49:17', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:19:59";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:49:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:49:59', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247905
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3266,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 14:49:59', userid = '2' WHERE clientid = '3266';
UPDATE client SET  inUse = 0 where clientid = 3266;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3266','1798.00','1798','1','ايصال تحصيل (( قبض من عميل ))','247905', '0', '2024-12-20 14:49:17', '2', 'clientPayedDeptController.php', '   ', '1798', '0', null, '0', null, null,'', '-1','1','1','1798','1','','3630','0');
UPDATE save SET  savecurrentvalue = '119330.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('117532.50','1798', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247905', '119330.5', '2024-12-20 14:49:59', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('فاطمة ابو ليلة 73', 'فاطمة ابو ليلة 73', 'فاطمة ابو ليلة 73', 'فاطمة ابو ليلة 73', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 14:49:59');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1798', '1798', '2024-12-20', '2', '0', '0', '2024-12-20 14:49:59','اضافة ايصال سداد للعميل فاطمة ابو ليلة 73','1','0','0','0','247905','clientPayedDeptController.php?do=show&id=247905');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122290', '-1', '1798', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1798', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122290', '12605', '1798', '','0');
UPDATE accountstree SET name = 'فاطمة ابو ليلة 73', customName = 'فاطمة ابو ليلة 73', customNameEn = 'فاطمة ابو ليلة 73', nameEn = 'فاطمة ابو ليلة 73', parent = '58', accountNature = '0', theValue = '-1798', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 14:49:59' WHERE id = '12605';
UPDATE clientdebtchange SET clientid = '3266', clientdebtchangebefore = '1798.000', clientdebtchangeamount = '1798.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247905', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 14:49:17', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1798.00',discount='', reciptid='0', dailyentryid = '122290',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1798',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247905';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247905 -clientdebtchangeId = 247905
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:20:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 14:50:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 14:50:00', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:20:51";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:50:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:50:51', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'دفاتر', '', '100', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '20690',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('20790.00','100', '1', '1', 'إضافة مصروف', '25907', '20690', '2024-12-20 14:50:52', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'دفاتر', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25907';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:20:52";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:50:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:50:52', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:20:54";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:50:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 14:50:54', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:23:29";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:53:29", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:53:29', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067656663503d7
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7584,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:43:15', '067656663503d7', '7584', '21.00', '2395', '0', '1', '2374.00', '2374', '0', '2374', '1', '2024-12-20 14:53:29', '', '75', '0', 'سالي امين U400', '2', '1', '3', '91', 'سالي امين U400', '6' ,'0','','','','','-1','0','0','0','0','0','2374','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2395', userid = '75' WHERE clientid = '7584';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7584','21.00','2374','0','اضافة فاتورة مبيعات','150389', '2395', '2024-12-20 14:53:29', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2374', '0', null, '0', null, null,'', '0','1','1','2374','1','2024-12-20 14:43:15','0','0');
UPDATE client SET  inUse = 0 where clientid = 7584;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36356;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('440','H1623', '150389', '14', '16312', '1', '530', '530', '0', '', '1', '2024-12-20 14:53:29', '16312', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36356-1,','1','1','0','0','530','530','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 440.00 , meanbuyprice = 440.00, lastbuyprice_withDiscount = 440.00, meanbuyprice_withDiscount = 440.00
        , lastbuyprice_withTax = 440, meanbuyprice_withTax = 440, lastbuyprice_withDiscountAndTax = 440
                where sellbilldetailid = 549455;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16312, '2024-12-20', 530, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+440
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 530, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+440
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '16', userid = '75', storedetaildate = '2024-12-20 14:53:29' WHERE storedetailid = '16311';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16312', '1', '1', '1', '150389', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-20 14:53:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35915;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('470','H1599', '150389', '14', '16217', '1', '580', '580', '0', '', '1', '2024-12-20 14:53:29', '16217', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35915-1,','1','1','0','0','580','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 470.00 , meanbuyprice = 470.00, lastbuyprice_withDiscount = 470.00, meanbuyprice_withDiscount = 470.00
        , lastbuyprice_withTax = 470, meanbuyprice_withTax = 470, lastbuyprice_withDiscountAndTax = 470
                where sellbilldetailid = 549456;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16217, '2024-12-20', 580, 470, 470
                    , 470, 470, 470, 470
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 470, 470, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+470
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+470, sellCostMeanBuyPrice = sellCostMeanBuyPrice+470
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+470, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+470
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+470
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+470
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+470
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 580, 470, 470
                    , 470, 470, 470, 470
                    , 0, 0, 0, 0
                    , 0, 0, 0, 470, 470, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+470
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+470, sellCostMeanBuyPrice = sellCostMeanBuyPrice+470
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+470, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+470
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+470
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+470
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+470
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '75', storedetaildate = '2024-12-20 14:53:29' WHERE storedetailid = '16216';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16217', '1', '1', '1', '150389', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-20 14:53:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36015;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('325','H1641', '150389', '14', '16346', '1', '400', '400', '0', '', '1', '2024-12-20 14:53:29', '16346', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36015-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 325.00 , meanbuyprice = 325.00, lastbuyprice_withDiscount = 325.00, meanbuyprice_withDiscount = 325.00
        , lastbuyprice_withTax = 325, meanbuyprice_withTax = 325, lastbuyprice_withDiscountAndTax = 325
                where sellbilldetailid = 549457;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16346, '2024-12-20', 400, 325, 325
                    , 325, 325, 325, 325
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 325, 325, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+325
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+325, sellCostMeanBuyPrice = sellCostMeanBuyPrice+325
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+325, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+325
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+325
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+325
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+325
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 325, 325
                    , 325, 325, 325, 325
                    , 0, 0, 0, 0
                    , 0, 0, 0, 325, 325, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+325
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+325, sellCostMeanBuyPrice = sellCostMeanBuyPrice+325
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+325, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+325
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+325
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+325
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+325
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '18', userid = '75', storedetaildate = '2024-12-20 14:53:29' WHERE storedetailid = '16345';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16346', '1', '1', '1', '150389', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '75', '2024-12-20 14:53:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36094;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('730','07143', '150389', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-20 14:53:29', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36094-1,','1','1','0','0','810','810','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 730.00 , meanbuyprice = 730.00, lastbuyprice_withDiscount = 730.00, meanbuyprice_withDiscount = 730.00
        , lastbuyprice_withTax = 730, meanbuyprice_withTax = 730, lastbuyprice_withDiscountAndTax = 730
                where sellbilldetailid = 549458;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16205, '2024-12-20', 810, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+730
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+730, sellCostMeanBuyPrice = sellCostMeanBuyPrice+730
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+730, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+730
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+730
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+730
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+730
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 810, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0, 730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+730
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+730, sellCostMeanBuyPrice = sellCostMeanBuyPrice+730
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+730, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+730
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+730
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+730
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+730
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '58', userid = '75', storedetaildate = '2024-12-20 14:53:29' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '150389', 'اضافة فاتورة مبيعات', 'sellbillController.php', '59', '58', '75', '2024-12-20 14:53:29','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150389', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:53:29', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150389', '17', '10291', '1', '34', '34', '0', '', '1', '2024-12-20 14:53:29', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','34','34','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 91 where clientid = 7584;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2374, 1965, 1965
                    , 1965, 1965, 1965, 1965
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1965, 1965, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2374, sellCostBuyPrice =sellCostBuyPrice+1965
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1965, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1965
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1965, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1965
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1965
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1965
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1965
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7584, '2024-12-20', 2374, 1965, 1965
                    , 1965, 1965, 1965, 1965
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1965, 1965, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2374, sellCostBuyPrice =sellCostBuyPrice+1965
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1965, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1965
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1965, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1965
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1965
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1965
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1965
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2374, 1965, 1965
                    , 1965, 1965, 1965, 1965, 1965, 1965)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2374, netSellCostBuyPrice = netSellCostBuyPrice+1965
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1965
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1965
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1965
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1965
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1965
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1965
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1965;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067656663503d7 and sellbillId = 150389 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:23:30";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:53:30", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:53:30', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:23:38";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:53:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:53:38', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE userid = 101;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:24:40";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:54:40", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 14:54:40', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:24:41";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:24:42";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:54:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 14:54:42', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:24:42";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:24:45";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:54:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 14:54:45', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:24:52";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:54:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 14:54:52', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:25:04";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:55:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 14:55:04', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:25:32";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:55:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:55:32', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676568d26fab5
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:53:38', '0676568d26fab5', '1', '0.00', '0', '0', '1', '1430.00', '1430', '1430', '0', '1', '2024-12-20 14:55:32', '', '104', '0', 'نقدي', '1', '0', '3', '25', 'نقدي', '5' ,'0','','','','','-1','0','0','0','0','0','1430','0','','0','0','1430','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150390', '0', '2024-12-20 14:55:32', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1430', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:53:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35607;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('170','07132', '150390', '5', '16156', '1', '240', '240', '0', '', '1', '2024-12-20 14:55:32', '16156', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35607-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 549461;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16156, '2024-12-20', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '104', storedetaildate = '2024-12-20 14:55:32' WHERE storedetailid = '16155';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16156', '1', '1', '1', '150390', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-20 14:55:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36349;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('185','H1619', '150390', '14', '16298', '1', '250', '250', '0', '', '1', '2024-12-20 14:55:32', '16298', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36349-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 185.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 185.00
        , lastbuyprice_withTax = 185, meanbuyprice_withTax = 185, lastbuyprice_withDiscountAndTax = 185
                where sellbilldetailid = 549462;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16298, '2024-12-20', 250, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 185, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+185
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+185
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 250, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0, 185, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+185
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+185
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '24', userid = '104', storedetaildate = '2024-12-20 14:55:32' WHERE storedetailid = '16297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16298', '1', '1', '1', '150390', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '104', '2024-12-20 14:55:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35523;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('280','R3308', '150390', '1', '16119', '1', '340', '340', '0', '', '1', '2024-12-20 14:55:32', '16119', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35523-1,','1','1','0','0','340','340','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 280, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 549463;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16119, '2024-12-20', 340, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 340, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '104', storedetaildate = '2024-12-20 14:55:32' WHERE storedetailid = '16118';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16119', '1', '1', '1', '150390', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-20 14:55:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35986;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','07256', '150390', '5', '16331', '2', '300', '600', '0', '', '1', '2024-12-20 14:55:32', '16331', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35986-2,','1','1','0','0','300','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549464;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16331, '2024-12-20', 600, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '52', userid = '104', storedetaildate = '2024-12-20 14:55:32' WHERE storedetailid = '16330';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16331', '1', '2', '1', '150390', 'اضافة فاتورة مبيعات', 'sellbillController.php', '54', '52', '104', '2024-12-20 14:55:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22120',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('20690','1430', '0', '1', 'اضافة فاتورة مبيعات', '150390', '22120', '2024-12-20 14:55:32', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 25 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1430, 1115, 1115
                    , 1115, 1115, 1115, 1115
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1115, 1115, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1430, sellCostBuyPrice =sellCostBuyPrice+1115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1115
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1115
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1115
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1430, 1115, 1115
                    , 1115, 1115, 1115, 1115
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1115, 1115, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1430, sellCostBuyPrice =sellCostBuyPrice+1115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1115
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1115
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1115
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1430, 1115, 1115
                    , 1115, 1115, 1115, 1115, 1115, 1115)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1430, netSellCostBuyPrice = netSellCostBuyPrice+1115
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1115
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1115
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1115
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1115
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1115
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1115
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1115;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676568d26fab5 and sellbillId = 150390 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:25:33";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:55:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:55:33', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:25:43";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:55:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 14:55:43', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:25:43";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:25:45";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:55:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 14:55:45', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:25:47";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:55:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 14:55:47', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:25:57";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:55:57", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 14:55:57', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:26:06";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:56:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 14:56:06', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:26:11";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:56:11", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:56:11', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676568ca52b27
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(95,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:53:30', '0676568ca52b27', '95', '0.00', '970', '10', '1', '980.00', '970', '0', '970', '1', '2024-12-20 14:56:11', '', '75', '0', 'سارة شلبي f218', '2', '1', '3', '86', 'سارة شلبي f218', '6' ,'0','','','','','-1','0','0','0','0','0','970','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '970', userid = '75' WHERE clientid = '95';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('95','0.00','970','0','اضافة فاتورة مبيعات','150391', '970', '2024-12-20 14:56:11', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '970', '0', null, '0', null, null,'', '0','1','1','970','1','2024-12-20 14:53:30','0','0');
UPDATE client SET  inUse = 0 where clientid = 95;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34862;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('235','H1453', '150391', '14', '15835', '1', '300', '300', '0', '', '1', '2024-12-20 14:56:11', '15835', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34862-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 235.00
        , lastbuyprice_withTax = 235, meanbuyprice_withTax = 235, lastbuyprice_withDiscountAndTax = 235
                where sellbilldetailid = 549465;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15835, '2024-12-20', 296.9387755102, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+296.9387755102, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+235
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 296.9387755102, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+296.9387755102, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+235
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 14:56:11' WHERE storedetailid = '15834';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15835', '1', '1', '1', '150391', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 14:56:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36349;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('185','H1619', '150391', '14', '16298', '1', '250', '250', '0', '', '1', '2024-12-20 14:56:11', '16298', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36349-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 185.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 185.00
        , lastbuyprice_withTax = 185, meanbuyprice_withTax = 185, lastbuyprice_withDiscountAndTax = 185
                where sellbilldetailid = 549466;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16298, '2024-12-20', 247.44897959184, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 185, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+247.44897959184, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+185
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+185
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 247.44897959184, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0, 185, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+247.44897959184, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+185
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+185
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '23', userid = '75', storedetaildate = '2024-12-20 14:56:11' WHERE storedetailid = '16297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16298', '1', '1', '1', '150391', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '75', '2024-12-20 14:56:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35525;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('330','07117', '150391', '5', '16121', '1', '200', '200', '0', '', '1', '2024-12-20 14:56:11', '16121', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35525-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
        , lastbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 330
                where sellbilldetailid = 549467;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16121, '2024-12-20', 197.95918367347, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 330, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+197.95918367347, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 197.95918367347, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 330, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+197.95918367347, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '75', storedetaildate = '2024-12-20 14:56:11' WHERE storedetailid = '16120';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16121', '1', '1', '1', '150391', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '75', '2024-12-20 14:56:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36329;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07286', '150391', '5', '16420', '1', '200', '200', '0', '', '1', '2024-12-20 14:56:12', '16420', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36329-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549468;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16420, '2024-12-20', 197.95918367347, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+197.95918367347, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 197.95918367347, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+197.95918367347, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '75', storedetaildate = '2024-12-20 14:56:12' WHERE storedetailid = '16419';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16420', '1', '1', '1', '150391', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-20 14:56:12','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150391', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 14:56:12', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150391', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-20 14:56:12', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','10','10','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 86 where clientid = 95;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 970, 890, 890
                    , 890, 890, 890, 890
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,890, 560, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+970, sellCostBuyPrice =sellCostBuyPrice+890
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+890, sellCostMeanBuyPrice = sellCostMeanBuyPrice+890
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+890, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+890
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+890
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+890
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+560
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (95, '2024-12-20', 970, 890, 890
                    , 890, 890, 890, 890
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,890, 560, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+970, sellCostBuyPrice =sellCostBuyPrice+890
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+890, sellCostMeanBuyPrice = sellCostMeanBuyPrice+890
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+890, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+890
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+890
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+890
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+560
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 970, 890, 890
                    , 890, 890, 890, 890, 890, 560)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+970, netSellCostBuyPrice = netSellCostBuyPrice+890
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+890
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+890
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+890
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+890
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+890
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+890
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+560;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676568ca52b27 and sellbillId = 150391 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:26:12";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 14:56:12", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:56:12', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:26:17";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:56:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 14:56:17', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:26:54";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:56:54", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 14:56:54', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:27:03";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 14:57:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 14:57:03', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:27:43";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:57:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:57:43', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067656945a8f30
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:55:33', '067656945a8f30', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-20 14:57:44', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','300','0','','0','0','300','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150392', '0', '2024-12-20 14:57:44', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:55:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36359;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','07260', '150392', '5', '16374', '1', '300', '300', '0', '', '1', '2024-12-20 14:57:44', '16374', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36359-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 231.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 231.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 238, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549471;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16374, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '104', storedetaildate = '2024-12-20 14:57:44' WHERE storedetailid = '16373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16374', '1', '1', '1', '150392', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-20 14:57:44','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22420',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('22120','300', '0', '1', 'اضافة فاتورة مبيعات', '150392', '22420', '2024-12-20 14:57:44', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 300, 225, 225
                    , 231, 225, 231, 237.5, 225, 238)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+225
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+225
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+231
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+225
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+231
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+237.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+225
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+238;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067656945a8f30 and sellbillId = 150392 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:27:44";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:57:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:57:44', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:28:37";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:58:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:58:37', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676569c8d249c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:57:44', '0676569c8d249c', '1', '0.00', '0', '0', '1', '240.00', '240', '240', '0', '1', '2024-12-20 14:58:37', '', '104', '0', 'نقدي', '1', '0', '3', '21', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','240','0','','0','0','240','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150393', '0', '2024-12-20 14:58:37', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '240', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 14:57:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35607;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('170','07132', '150393', '5', '16156', '1', '240', '240', '0', '', '1', '2024-12-20 14:58:37', '16156', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35607-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 549472;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16156, '2024-12-20', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '104', storedetaildate = '2024-12-20 14:58:37' WHERE storedetailid = '16155';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16156', '1', '1', '1', '150393', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-20 14:58:37','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22660',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('22420','240', '0', '1', 'اضافة فاتورة مبيعات', '150393', '22660', '2024-12-20 14:58:37', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 21 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 240, 170, 170
                    , 170, 170, 170, 170, 170, 170)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+240, netSellCostBuyPrice = netSellCostBuyPrice+170
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+170
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+170
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+170
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+170
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+170;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676569c8d249c and sellbillId = 150393 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:28:38";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 14:58:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 14:58:38', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:31:19";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:01:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 15:01:19', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:32:35";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 15:02:35", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:02:35', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676565c0d0919
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7047,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:40:32', '0676565c0d0919', '7047', '0.00', '2076', '0', '1', '2076.00', '2076', '0', '2076', '1', '2024-12-20 15:02:35', '', '101', '0', 'هبة محمد G9', '2', '1', '3', '88', 'هبة محمد G9', '9' ,'0','','','','','-1','0','0','0','0','0','2076','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2076', userid = '101' WHERE clientid = '7047';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7047','0.00','2076','0','اضافة فاتورة مبيعات','150394', '2076', '2024-12-20 15:02:35', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2076', '0', null, '0', null, null,'', '0','1','1','2076','1','2024-12-20 14:40:32','0','0');
UPDATE client SET  inUse = 0 where clientid = 7047;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36142;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07226', '150394', '5', '16294', '1', '210', '210', '0', '', '1', '2024-12-20 15:02:35', '16294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36142-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 151.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 151.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 153, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549473;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16294, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '69', userid = '101', storedetaildate = '2024-12-20 15:02:35' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '1', '150394', 'اضافة فاتورة مبيعات', 'sellbillController.php', '70', '69', '101', '2024-12-20 15:02:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35866;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','07191', '150394', '5', '16271', '1', '200', '200', '0', '', '1', '2024-12-20 15:02:35', '16271', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35866-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145
                where sellbilldetailid = 549474;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16271, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '101', storedetaildate = '2024-12-20 15:02:35' WHERE storedetailid = '16270';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16271', '1', '1', '1', '150394', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '101', '2024-12-20 15:02:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35439;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('370','07070', '150394', '5', '16055', '1', '450', '450', '0', '', '1', '2024-12-20 15:02:35', '16055', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35439-1,','1','1','0','0','450','450','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 370.00 , meanbuyprice = 346.00, lastbuyprice_withDiscount = 370.00, meanbuyprice_withDiscount = 346.00
        , lastbuyprice_withTax = 370, meanbuyprice_withTax = 346
                where sellbilldetailid = 549475;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16055, '2024-12-20', 450, 370, 370
                    , 346, 370, 346, 370
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 370, 346, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+346
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+346
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+370
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+370
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+346
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 450, 370, 370
                    , 346, 370, 346, 370
                    , 0, 0, 0, 0
                    , 0, 0, 0, 370, 346, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+346
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+346
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+370
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+370
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+346
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '101', storedetaildate = '2024-12-20 15:02:35' WHERE storedetailid = '16054';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16055', '1', '1', '1', '150394', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '101', '2024-12-20 15:02:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35397;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('215','0K789', '150394', '7', '15760', '1', '275', '275', '0', '', '1', '2024-12-20 15:02:35', '15760', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35397-1,','1','1','0','0','275','275','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 215.00 , meanbuyprice = 215.00, lastbuyprice_withDiscount = 215.00, meanbuyprice_withDiscount = 215.00
        , lastbuyprice_withTax = 215, meanbuyprice_withTax = 215, lastbuyprice_withDiscountAndTax = 215
                where sellbilldetailid = 549476;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15760, '2024-12-20', 275, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 215, 215, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+215
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 275, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 215, 215, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+215
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '21', userid = '101', storedetaildate = '2024-12-20 15:02:35' WHERE storedetailid = '15759';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15760', '1', '1', '1', '150394', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '101', '2024-12-20 15:02:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33936;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('270','R3171', '150394', '1', '15299', '1', '320', '320', '0', '', '1', '2024-12-20 15:02:35', '15299', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33936-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 270.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 270.00, meanbuyprice_withDiscount = 270.00
        
                where sellbilldetailid = 549477;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15299, '2024-12-20', 320, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-20 15:02:35' WHERE storedetailid = '15298';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15299', '1', '1', '1', '150394', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '101', '2024-12-20 15:02:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34638;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('320','06848', '150394', '5', '15577', '1', '380', '380', '0', '', '1', '2024-12-20 15:02:35', '15577', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34638-1,','1','1','0','0','380','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
        , lastbuyprice_withTax = 320, meanbuyprice_withTax = 185, lastbuyprice_withDiscountAndTax = 320
                where sellbilldetailid = 549478;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15577, '2024-12-20', 380, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 320, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+320
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+185
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 380, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+320
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+185
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '101', storedetaildate = '2024-12-20 15:02:35' WHERE storedetailid = '15576';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15577', '1', '1', '1', '150394', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '101', '2024-12-20 15:02:35','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07044', '150394', '5', '16023', '1', '200', '200', '0', '', '1', '2024-12-20 15:02:35', '16023', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549479;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16023, '2024-12-20', 200, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-6', userid = '101', storedetaildate = '2024-12-20 15:02:35' WHERE storedetailid = '16022';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16023', '1', '1', '1', '150394', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-5', '-6', '101', '2024-12-20 15:02:35','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150394', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 15:02:35', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150394', '17', '10291', '1', '21', '21', '0', '', '1', '2024-12-20 15:02:35', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','21','21','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 88 where clientid = 7047;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2076, 1630, 1630
                    , 1602, 1630, 1602, 1628.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1360, 1199, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2076, sellCostBuyPrice =sellCostBuyPrice+1630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1602
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1602
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1628.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1199
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7047, '2024-12-20', 2076, 1630, 1630
                    , 1602, 1630, 1602, 1628.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1360, 1199, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2076, sellCostBuyPrice =sellCostBuyPrice+1630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1602
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1602
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1628.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1199
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2076, 1630, 1630
                    , 1602, 1630, 1602, 1628.12, 1360, 1199)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2076, netSellCostBuyPrice = netSellCostBuyPrice+1630
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1630
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1602
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1630
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1602
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1628.12
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1360
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1199;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676565c0d0919 and sellbillId = 150394 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:32:36";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 15:02:36", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:02:36', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:33:01";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 15:03:01", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 15:03:01', '101', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:33:01";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:33:05";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 15:03:05", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:03:05', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:33:11";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 15:03:11", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:03:11', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:33:30";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 15:03:30", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:03:30', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150394');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:33:33";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:03:33", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:03:33', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765696ccc31f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8520,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 14:56:12', '06765696ccc31f', '8520', '1.00', '1284', '0', '1', '1283.00', '1283', '0', '1283', '1', '2024-12-20 15:03:33', '', '75', '0', 'شروق احمد T203', '2', '1', '3', '89', 'شروق احمد T203', '7' ,'0','','','','','-1','0','0','0','0','0','1283','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1284', userid = '75' WHERE clientid = '8520';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8520','1.00','1283','0','اضافة فاتورة مبيعات','150395', '1284', '2024-12-20 15:03:33', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1283', '0', null, '0', null, null,'', '0','1','1','1283','1','2024-12-20 14:56:12','0','0');
UPDATE client SET  inUse = 0 where clientid = 8520;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33458;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','R3109', '150395', '1', '15026', '1', '210', '210', '0', '', '1', '2024-12-20 15:03:33', '15026', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33458-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        
                where sellbilldetailid = 549482;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15026, '2024-12-20', 210, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 15:03:33' WHERE storedetailid = '15025';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15026', '1', '1', '1', '150395', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 15:03:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35982;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('355','07234', '150395', '5', '16327', '1', '400', '400', '0', '', '1', '2024-12-20 15:03:33', '16327', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35982-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 359.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 359.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 358, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549483;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16327, '2024-12-20', 400, 360, 360
                    , 359, 360, 359, 357.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 358, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+359
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+359
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+357.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+358
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 360, 360
                    , 359, 360, 359, 357.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 358, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+359
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+359
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+357.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+358
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '75', storedetaildate = '2024-12-20 15:03:33' WHERE storedetailid = '16326';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16327', '1', '1', '1', '150395', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '75', '2024-12-20 15:03:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35812;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','R3320', '150395', '1', '16236', '1', '200', '200', '0', '', '1', '2024-12-20 15:03:33', '16236', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35812-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 73, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549484;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16236, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 73, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+73
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 73, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+73
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '75', storedetaildate = '2024-12-20 15:03:33' WHERE storedetailid = '16235';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16236', '1', '1', '1', '150395', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-20 15:03:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35861;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','07187', '150395', '5', '16267', '1', '200', '200', '0', '', '1', '2024-12-20 15:03:33', '16267', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35861-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549485;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16267, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '75', storedetaildate = '2024-12-20 15:03:33' WHERE storedetailid = '16266';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16267', '1', '1', '1', '150395', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-20 15:03:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36167;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','07131', '150395', '5', '16152', '1', '240', '240', '0', '', '1', '2024-12-20 15:03:33', '16152', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36167-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 549486;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16152, '2024-12-20', 240, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 240, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '23', userid = '75', storedetaildate = '2024-12-20 15:03:33' WHERE storedetailid = '16151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16152', '1', '1', '1', '150395', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '75', '2024-12-20 15:03:33','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150395', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 15:03:34', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150395', '17', '10291', '1', '13', '13', '0', '', '1', '2024-12-20 15:03:34', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','13','13','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 89 where clientid = 8520;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1283, 1005, 1005
                    , 1004, 1005, 1004, 1002.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,850, 776, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1283, sellCostBuyPrice =sellCostBuyPrice+1005
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1005, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1004
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1005, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1004
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1002.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+850
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+776
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8520, '2024-12-20', 1283, 1005, 1005
                    , 1004, 1005, 1004, 1002.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,850, 776, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1283, sellCostBuyPrice =sellCostBuyPrice+1005
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1005, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1004
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1005, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1004
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1002.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+850
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+776
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1283, 1005, 1005
                    , 1004, 1005, 1004, 1002.5, 850, 776)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1283, netSellCostBuyPrice = netSellCostBuyPrice+1005
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1005
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1004
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1005
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1004
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1002.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+850
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+776;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765696ccc31f and sellbillId = 150395 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:33:34";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:03:34", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:03:34', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:34:34";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:04:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:04:34', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:37:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:07:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:07:01', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247906
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10678,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 15:07:01', userid = '2' WHERE clientid = '10678';
UPDATE client SET  inUse = 0 where clientid = 10678;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10678','763.00','763','1','ايصال تحصيل (( قبض من عميل ))','247906', '0', '2024-12-20 14:50:00', '2', 'clientPayedDeptController.php', '   ', '763', '0', null, '0', null, null,'', '-1','1','1','763','1','','3631','0');
UPDATE save SET  savecurrentvalue = '120093.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('119330.50','763', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247913', '120093.5', '2024-12-20 15:07:01', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '763', '763', '2024-12-20', '2', '0', '0', '2024-12-20 15:07:01','اضافة ايصال سداد للعميل محمد سلمان 52','1','0','0','0','247913','clientPayedDeptController.php?do=show&id=247913');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122291', '-1', '763', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '763', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122291', '12409', '763', '','0');
UPDATE accountstree SET name = 'محمد سلمان 52', customName = 'محمد سلمان 52', customNameEn = 'محمد سلمان 52', nameEn = 'محمد سلمان 52', parent = '58', accountNature = '0', theValue = '-1440', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-12 11:23:20' WHERE id = '12409';
UPDATE clientdebtchange SET clientid = '10678', clientdebtchangebefore = '763.000', clientdebtchangeamount = '763.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247906', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 14:50:00', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '763.00',discount='', reciptid='0', dailyentryid = '122291',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='763',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247913';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247906 -clientdebtchangeId = 247913
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:37:02";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:07:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:07:02', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:37:24";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:07:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:07:24', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247914
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(539,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 15:07:25', userid = '2' WHERE clientid = '539';
UPDATE client SET  inUse = 0 where clientid = 539;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('539','838.00','838','1','ايصال تحصيل (( قبض من عميل ))','247914', '0', '2024-12-20 15:07:02', '2', 'clientPayedDeptController.php', '   ', '838', '0', null, '0', null, null,'', '-1','1','1','838','1','','3632','0');
UPDATE save SET  savecurrentvalue = '120931.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('120093.50','838', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247914', '120931.5', '2024-12-20 15:07:25', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '838', '838', '2024-12-20', '2', '0', '0', '2024-12-20 15:07:25','اضافة ايصال سداد للعميل عزة محمود T71','1','0','0','0','247914','clientPayedDeptController.php?do=show&id=247914');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122292', '-1', '838', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '838', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122292', '-1', '838', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-838', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '539', clientdebtchangebefore = '838.000', clientdebtchangeamount = '838.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247914', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 15:07:02', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '838.00',discount='', reciptid='0', dailyentryid = '122292',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='838',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247914';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247914 -clientdebtchangeId = 247914
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:37:26";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:07:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:07:26', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('مكة احمد 25' , '', '', '01030927763', '0', '', '0', '2024-12-20 15:07:32', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10765', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10765','0','0','0','إضافة عميل جديد','10765', '0', '2024-12-20 15:07:32', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('مكة احمد 25', 'مكة احمد 25', 'مكة احمد 25', 'مكة احمد 25', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-20 15:07:32');
UPDATE client SET clientname = 'مكة احمد 25', clientaddress = '', clientphone = '', clientmobile = '01030927763', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '75'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12606',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10765';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:37:49";
UPDATE user SET loginip = "192.168.1.31", lastactivetime = "2024-12-20 15:07:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 15:07:49', '2', 'show', '192.168.1.31', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:38:02";
UPDATE user SET loginip = "192.168.1.31", lastactivetime = "2024-12-20 15:08:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:08:02', '2', 'addsellBill', '192.168.1.31', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:38:09";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:08:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:08:09', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('ياسمين اسماعيل 77' , '', '', '012255877276', '0', '', '0', '2024-12-20 15:08:26', '2', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10766', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10766','0','0','0','إضافة عميل جديد','10766', '0', '2024-12-20 15:08:26', '2', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('ياسمين اسماعيل 77', 'ياسمين اسماعيل 77', 'ياسمين اسماعيل 77', 'ياسمين اسماعيل 77', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 15:08:26');
UPDATE client SET clientname = 'ياسمين اسماعيل 77', clientaddress = '', clientphone = '', clientmobile = '012255877276', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '2'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12607',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10766';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:38:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:08:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:08:28', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067656c39da754
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 15:08:09', '067656c39da754', '1', '0.00', '0', '0', '1', '470', '470', '-470', '0', '1', '2024-12-20 15:08:28', '', '104', '0', 'نقدي','1', '0', '5', '5', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-470','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16849', '0', '2024-12-20 15:08:28', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '470', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 15:08:09','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('385.00', 'H1248', '16849', '14', '11045', '1', '470', '470', '0', '', '1', '0', '11045', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','470','470','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 385.00 , meanbuyprice = 385.00, lastbuyprice_withDiscount = 385.00, meanbuyprice_withDiscount = 385.00
        
                where returnsellbilldetailid = 22039;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11045, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 470, 385, 385, 385
                    , 385, 385, 0, 0, 1, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+470, returnSellCostBuyPrice = returnSellCostBuyPrice+385, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+385
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+385, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+385
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+385
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 470, 385, 385, 385
                    , 385, 385, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+470, returnSellCostBuyPrice = returnSellCostBuyPrice+385, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+385
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+385, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+385
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+385
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '104', storedetaildate = '2024-12-20 15:08:28' WHERE storedetailid = '11044';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11045', '1', '1', '0', '16849', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '1', '2', '104', '2024-12-20 15:08:28','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22190',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('22660','-470', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16849', '22190', '2024-12-20 15:08:28', '104',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 470, 385, 385, 385
                    , 385, 385, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+470, returnSellCostBuyPrice = returnSellCostBuyPrice+385, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+385
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+385, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+385
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+385
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 470, 385, 385, 385
                    , 385, 385, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+470, returnSellCostBuyPrice = returnSellCostBuyPrice+385, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+385
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+385, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+385
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+385
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -470, -385, -385
                    , -385, -385, -385, 0, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-470, netSellCostBuyPrice = netSellCostBuyPrice+-385
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-385
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-385
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-385
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-385
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067656c39da754 and sellbillId = 16849 and returnsellbillId = 16849
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:38:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:08:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:08:28', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:38:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:08:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:08:46', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('نادية الشروق 33' , '', '', '01117639522', '0', '', '0', '2024-12-20 15:09:05', '2', '0','','0','','-10','0','0',',','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10767', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10767','0','0','0','إضافة عميل جديد','10767', '0', '2024-12-20 15:09:05', '2', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('نادية الشروق 33', 'نادية الشروق 33', 'نادية الشروق 33', 'نادية الشروق 33', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 15:09:05');
UPDATE client SET clientname = 'نادية الشروق 33', clientaddress = '', clientphone = '', clientmobile = '01117639522', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '2'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='0' , typeclientid=',',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12608',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10767';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:39:43";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:09:43", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:09:43', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067656b26cd17a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10765,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:03:34', '067656b26cd17a', '10765', '0.00', '2369', '0', '1', '2369.00', '2369', '0', '2369', '1', '2024-12-20 15:09:44', '', '75', '0', 'مكة احمد 25', '2', '1', '3', '78', 'مكة احمد 25', '6' ,'0','','','','','-1','0','0','0','0','0','2369','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2369', userid = '75' WHERE clientid = '10765';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10765','0.00','2369','0','اضافة فاتورة مبيعات','150396', '2369', '2024-12-20 15:09:44', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2369', '0', null, '0', null, null,'', '0','1','1','2369','1','2024-12-20 15:03:34','0','0');
UPDATE client SET  inUse = 0 where clientid = 10765;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35689;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('530','07147', '150396', '5', '16193', '1', '600', '600', '0', '', '1', '2024-12-20 15:09:44', '16193', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35689-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 530.00 , meanbuyprice = 530.00, lastbuyprice_withDiscount = 530.00, meanbuyprice_withDiscount = 530.00
        , lastbuyprice_withTax = 530, meanbuyprice_withTax = 530, lastbuyprice_withDiscountAndTax = 530
                where sellbilldetailid = 549489;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16193, '2024-12-20', 600, 530, 530
                    , 530, 530, 530, 529.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 530, 530, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+529.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+530
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+530
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 530, 530
                    , 530, 530, 530, 529.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 530, 530, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+529.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+530
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+530
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '75', storedetaildate = '2024-12-20 15:09:44' WHERE storedetailid = '16192';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16193', '1', '1', '1', '150396', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-20 15:09:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36006;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('650','H1601', '150396', '14', '16226', '1', '800', '800', '0', '', '1', '2024-12-20 15:09:44', '16226', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36006-1,','1','1','0','0','800','800','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 650.00 , meanbuyprice = 650.00, lastbuyprice_withDiscount = 650.00, meanbuyprice_withDiscount = 650.00
        , lastbuyprice_withTax = 650, lastbuyprice_withDiscountAndTax = 650
                where sellbilldetailid = 549490;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16226, '2024-12-20', 800, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 650, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 800, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0, 650, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '75', storedetaildate = '2024-12-20 15:09:44' WHERE storedetailid = '16225';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16226', '1', '1', '1', '150396', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '75', '2024-12-20 15:09:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36147;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('495','07196', '150396', '5', '16254', '1', '650', '650', '0', '', '1', '2024-12-20 15:09:44', '16254', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36147-1,','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 495.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 495.00
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 495, lastbuyprice_withDiscountAndTax = 495
                where sellbilldetailid = 549491;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16254, '2024-12-20', 650, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+495
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 650, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+495
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '75', storedetaildate = '2024-12-20 15:09:44' WHERE storedetailid = '16253';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16254', '1', '1', '1', '150396', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-20 15:09:44','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('300','06581', '150396', '5', '15004', '1', '275', '275', '0', '', '1', '2024-12-20 15:09:44', '15004', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','275','275','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        
                where sellbilldetailid = 549492;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15004, '2024-12-20', 275, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 275, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 15:09:44' WHERE storedetailid = '15003';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15004', '1', '1', '1', '150396', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 15:09:44','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150396', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 15:09:44', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150396', '17', '10291', '1', '24', '24', '0', '', '1', '2024-12-20 15:09:44', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','24','24','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 78 where clientid = 10765;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2369, 1975, 1975
                    , 1975, 1975, 1975, 1974.75
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1675, 1025, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2369, sellCostBuyPrice =sellCostBuyPrice+1975
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1975, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1975
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1975, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1975
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1974.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1675
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1025
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10765, '2024-12-20', 2369, 1975, 1975
                    , 1975, 1975, 1975, 1974.75
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1675, 1025, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2369, sellCostBuyPrice =sellCostBuyPrice+1975
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1975, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1975
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1975, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1975
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1974.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1675
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1025
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2369, 1975, 1975
                    , 1975, 1975, 1975, 1974.75, 1675, 1025)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2369, netSellCostBuyPrice = netSellCostBuyPrice+1975
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1975
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1975
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1975
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1975
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1974.75
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1675
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1025;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067656b26cd17a and sellbillId = 150396 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:39:45";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:09:45", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:09:45', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('هند عوت ' , '', '', '0104799868', '0', '', '0', '2024-12-20 15:10:14', '2', '0','','0','','-10','0','0',',','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10768', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10768','0','0','0','إضافة عميل جديد','10768', '0', '2024-12-20 15:10:14', '2', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('هند عوت ', 'هند عوت ', 'هند عوت ', 'هند عوت ', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 15:10:14');
UPDATE client SET clientname = 'هند عوت ', clientaddress = '', clientphone = '', clientmobile = '0104799868', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '2'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='0' , typeclientid=',',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12609',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10768';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:40:18";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:10:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:10:18', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247918
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2258,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 15:10:18', userid = '104' WHERE clientid = '2258';
UPDATE client SET  inUse = 0 where clientid = 2258;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2258','4330.00','4330','1','ايصال تحصيل (( قبض من عميل ))','247918', '0', '2024-12-20 15:08:47', '104', 'clientPayedDeptController.php', '   ', '4330', '0', null, '0', null, null,'', '-1','1','1','4330','1','','3633','0');
UPDATE save SET  savecurrentvalue = '26520',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('22190.00','4330', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '247921', '26520', '2024-12-20 15:10:18', '104',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '4330', '4330', '2024-12-20', '104', '0', '0', '2024-12-20 15:10:18','اضافة ايصال سداد للعميل ماجي محمد W3','1','0','-1','0','247921','clientPayedDeptController.php?do=show&id=247921');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122293', '-1', '4330', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '4330', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122293', '-1', '4330', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-4330', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '2258', clientdebtchangebefore = '4330.000', clientdebtchangeamount = '4330.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247918', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 15:08:47', userid = '104', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '4330.00',discount='', reciptid='0', dailyentryid = '122293',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='4330',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247921';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247918 -clientdebtchangeId = 247921
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:40:19";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:10:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:10:19', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:40:20";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:10:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:10:20', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('روان السويس 25' , '', '', '01013835499', '0', '', '0', '2024-12-20 15:10:39', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10769', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10769','0','0','0','إضافة عميل جديد','10769', '0', '2024-12-20 15:10:39', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('روان السويس 25', 'روان السويس 25', 'روان السويس 25', 'روان السويس 25', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-20 15:10:39');
UPDATE client SET clientname = 'روان السويس 25', clientaddress = '', clientphone = '', clientmobile = '01013835499', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '75'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12610',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10769';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:40:45";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:10:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:10:45', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247915
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10766,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-300' , clientdate = '2024-12-20 15:10:45', userid = '2' WHERE clientid = '10766';
UPDATE client SET  inUse = 0 where clientid = 10766;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10766','0.00','300','1','ايصال تحصيل (( قبض من عميل ))','247915', '-300', '2024-12-20 15:07:26', '2', 'clientPayedDeptController.php', '   ', '300', '0', null, '0', null, null,'', '-1','1','1','300','1','','3633','0');
UPDATE save SET  savecurrentvalue = '121231.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('120931.50','300', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247923', '121231.5', '2024-12-20 15:10:45', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '300', '300', '2024-12-20', '2', '0', '0', '2024-12-20 15:10:45','اضافة ايصال سداد للعميل ياسمين اسماعيل 77','1','0','0','0','247923','clientPayedDeptController.php?do=show&id=247923');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122294', '-1', '300', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '300', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122294', '12607', '300', '','0');
UPDATE accountstree SET name = 'ياسمين اسماعيل 77', customName = 'ياسمين اسماعيل 77', customNameEn = 'ياسمين اسماعيل 77', nameEn = 'ياسمين اسماعيل 77', parent = '58', accountNature = '0', theValue = '-300', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 15:08:26' WHERE id = '12607';
UPDATE clientdebtchange SET clientid = '10766', clientdebtchangebefore = '0.000', clientdebtchangeamount = '300.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247915', clientdebtchangeafter = '-300.000', clientdebtchangedate = '2024-12-20 15:07:26', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '300.00',discount='', reciptid='0', dailyentryid = '122294',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='300',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247923';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247915 -clientdebtchangeId = 247923
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:40:45";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:10:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:10:45', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:40:48";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:10:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:10:48', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:41:06";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:11:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:11:06', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067656cd83a9b4
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:10:48', '067656cd83a9b4', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2024-12-20 15:11:07', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150397', '0', '2024-12-20 15:11:07', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 15:10:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36500;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07316', '150397', '5', '16486', '1', '200', '200', '0', '', '1', '2024-12-20 15:11:07', '16486', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36500-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549495;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16486, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '104', storedetaildate = '2024-12-20 15:11:07' WHERE storedetailid = '16485';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16486', '1', '1', '1', '150397', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-20 15:11:07','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '26720',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26520','200', '0', '1', 'اضافة فاتورة مبيعات', '150397', '26720', '2024-12-20 15:11:07', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 200, 140, 140
                    , 140, 140, 140, 140, 140, 140)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+140
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+140
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+140
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+140
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+140
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+140
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+140;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067656cd83a9b4 and sellbillId = 150397 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:41:07";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:11:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:11:07', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247924
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10767,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-400' , clientdate = '2024-12-20 15:11:07', userid = '2' WHERE clientid = '10767';
UPDATE client SET  inUse = 0 where clientid = 10767;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10767','0.00','400','1','ايصال تحصيل (( قبض من عميل ))','247924', '-400', '2024-12-20 15:10:45', '2', 'clientPayedDeptController.php', '   ', '400', '0', null, '0', null, null,'', '-1','1','1','400','1','','3634','0');
UPDATE save SET  savecurrentvalue = '121631.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('121231.50','400', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247925', '121631.5', '2024-12-20 15:11:07', '2',  'clientPayedDeptController.php','0','','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:41:07";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:11:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:11:07', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '400', '400', '2024-12-20', '2', '0', '0', '2024-12-20 15:11:07','اضافة ايصال سداد للعميل نادية الشروق 33','1','0','0','0','247925','clientPayedDeptController.php?do=show&id=247925');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122295', '-1', '400', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '400', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122295', '12608', '400', '','0');
UPDATE accountstree SET name = 'نادية الشروق 33', customName = 'نادية الشروق 33', customNameEn = 'نادية الشروق 33', nameEn = 'نادية الشروق 33', parent = '58', accountNature = '0', theValue = '-400', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 15:09:05' WHERE id = '12608';
UPDATE clientdebtchange SET clientid = '10767', clientdebtchangebefore = '0.000', clientdebtchangeamount = '400.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247924', clientdebtchangeafter = '-400.000', clientdebtchangedate = '2024-12-20 15:10:45', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '400.00',discount='', reciptid='0', dailyentryid = '122295',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='400',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247925';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247924 -clientdebtchangeId = 247925
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:41:08";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:11:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:11:08', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:41:25";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:11:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:11:25', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247926
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10768,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-300' , clientdate = '2024-12-20 15:11:25', userid = '2' WHERE clientid = '10768';
UPDATE client SET  inUse = 0 where clientid = 10768;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10768','0.00','300','1','ايصال تحصيل (( قبض من عميل ))','247926', '-300', '2024-12-20 15:11:08', '2', 'clientPayedDeptController.php', '   ', '300', '0', null, '0', null, null,'', '-1','1','1','300','1','','3635','0');
UPDATE save SET  savecurrentvalue = '121931.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('121631.50','300', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247926', '121931.5', '2024-12-20 15:11:25', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '300', '300', '2024-12-20', '2', '0', '0', '2024-12-20 15:11:25','اضافة ايصال سداد للعميل هند عوت ','1','0','0','0','247926','clientPayedDeptController.php?do=show&id=247926');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122296', '-1', '300', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '300', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122296', '12609', '300', '','0');
UPDATE accountstree SET name = 'هند عوت ', customName = 'هند عوت ', customNameEn = 'هند عوت ', nameEn = 'هند عوت ', parent = '58', accountNature = '0', theValue = '-300', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 15:10:14' WHERE id = '12609';
UPDATE clientdebtchange SET clientid = '10768', clientdebtchangebefore = '0.000', clientdebtchangeamount = '300.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247926', clientdebtchangeafter = '-300.000', clientdebtchangedate = '2024-12-20 15:11:08', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '300.00',discount='', reciptid='0', dailyentryid = '122296',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='300',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247926';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247926 -clientdebtchangeId = 247926
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:41:26";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:11:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:11:26', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:41:27";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:11:27", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:11:27', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067656c9939884
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10769,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:09:45', '067656c9939884', '10769', '0.00', '222', '0', '1', '222.00', '222', '0', '222', '1', '2024-12-20 15:11:27', '', '75', '0', 'روان السويس 25', '2', '1', '3', '78', 'روان السويس 25', '3' ,'0','','','','','-1','0','0','0','0','0','222','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '222', userid = '75' WHERE clientid = '10769';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10769','0.00','222','0','اضافة فاتورة مبيعات','150398', '222', '2024-12-20 15:11:27', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '222', '0', null, '0', null, null,'', '0','1','1','222','1','2024-12-20 15:09:45','0','0');
UPDATE client SET  inUse = 0 where clientid = 10769;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36320;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('165','R3336', '150398', '1', '16417', '1', '200', '200', '0', '', '1', '2024-12-20 15:11:27', '16417', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36320-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549496;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16417, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '75', storedetaildate = '2024-12-20 15:11:27' WHERE storedetailid = '16416';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16417', '1', '1', '1', '150398', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '75', '2024-12-20 15:11:27','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150398', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 15:11:27', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150398', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-20 15:11:27', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','2','2','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 78 where clientid = 10769;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 222, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+222, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10769, '2024-12-20', 222, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+222, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 222, 165, 165
                    , 165, 165, 165, 165, 165, 165)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+222, netSellCostBuyPrice = netSellCostBuyPrice+165
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+165
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+165
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+165
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+165
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+165
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+165
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+165;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067656c9939884 and sellbillId = 150398 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:41:28";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:11:28", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:11:28', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:43:09";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:13:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 15:13:09', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:43:33";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:13:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 15:13:33', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'نت المخازن', '', '1210', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '25510',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26720.00','1210', '1', '1', 'إضافة مصروف', '25908', '25510', '2024-12-20 15:13:34', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'نت المخازن', expensesdetails = '', expensesValue = '1210.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25908';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:43:34";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:13:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 15:13:34', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:43:36";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:13:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 15:13:36', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:45:22";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:15:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:15:22', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247927
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9493,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 15:15:22', userid = '2' WHERE clientid = '9493';
UPDATE client SET  inUse = 0 where clientid = 9493;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9493','242.00','242','1','ايصال تحصيل (( قبض من عميل ))','247927', '0', '2024-12-20 15:11:26', '2', 'clientPayedDeptController.php', '   ', '242', '0', null, '0', null, null,'', '-1','1','1','242','1','','3636','0');
UPDATE save SET  savecurrentvalue = '122173.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('121931.50','242', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247928', '122173.5', '2024-12-20 15:15:22', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '242', '242', '2024-12-20', '2', '0', '0', '2024-12-20 15:15:22','اضافة ايصال سداد للعميل د/ اسراء','1','0','0','0','247928','clientPayedDeptController.php?do=show&id=247928');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122297', '-1', '242', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '242', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122297', '-1', '242', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-242', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '9493', clientdebtchangebefore = '242.000', clientdebtchangeamount = '242.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247927', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 15:11:26', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '242.00',discount='', reciptid='0', dailyentryid = '122297',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='242',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247928';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247927 -clientdebtchangeId = 247928
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:45:23";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:15:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:15:23', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:45:39";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:15:39", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:15:39', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067656d004bcad
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10431,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:11:28', '067656d004bcad', '10431', '-41.00', '1010', '0', '1', '1051.00', '1051', '0', '1051', '1', '2024-12-20 15:15:39', '', '75', '0', 'نجاح الصفح 43', '2', '1', '3', '91', 'نجاح الصفح 43', '6' ,'0','','','','','-1','0','0','0','0','0','1051','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1010', userid = '75' WHERE clientid = '10431';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10431','-41.00','1051','0','اضافة فاتورة مبيعات','150399', '1010', '2024-12-20 15:15:39', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1051', '0', null, '0', null, null,'', '0','1','1','1051','1','2024-12-20 15:11:28','0','0');
UPDATE client SET  inUse = 0 where clientid = 10431;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36368;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('150','07296', '150399', '5', '16435', '1', '200', '200', '0', '', '1', '2024-12-20 15:15:40', '16435', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36368-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        , lastbuyprice_withTax = 150, meanbuyprice_withTax = 150, lastbuyprice_withDiscountAndTax = 150
                where sellbilldetailid = 549499;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16435, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '75', storedetaildate = '2024-12-20 15:15:40' WHERE storedetailid = '16434';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16435', '1', '1', '1', '150399', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-20 15:15:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36387;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','H1669', '150399', '14', '16450', '1', '270', '270', '0', '', '1', '2024-12-20 15:15:40', '16450', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36387-1,','1','1','0','0','270','270','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 549500;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16450, '2024-12-20', 270, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 270, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '75', storedetaildate = '2024-12-20 15:15:40' WHERE storedetailid = '16449';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16450', '1', '1', '1', '150399', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '75', '2024-12-20 15:15:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36335;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('180','H1658', '150399', '14', '16424', '1', '250', '250', '0', '', '1', '2024-12-20 15:15:40', '16424', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36335-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
        , lastbuyprice_withTax = 180, meanbuyprice_withTax = 180, lastbuyprice_withDiscountAndTax = 180
                where sellbilldetailid = 549501;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16424, '2024-12-20', 250, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+180
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 250, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+180
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '75', storedetaildate = '2024-12-20 15:15:40' WHERE storedetailid = '16423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16424', '1', '1', '1', '150399', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-20 15:15:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34888;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('300','H1357', '150399', '14', '15477', '1', '300', '300', '0', '', '1', '2024-12-20 15:15:40', '15477', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34888-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 277, lastbuyprice_withDiscountAndTax = 300
                where sellbilldetailid = 549502;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15477, '2024-12-20', 300, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 300, 277, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+277
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 277, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+277
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '75', storedetaildate = '2024-12-20 15:15:40' WHERE storedetailid = '15476';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15477', '1', '1', '1', '150399', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-20 15:15:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150399', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 15:15:40', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150399', '17', '10291', '1', '11', '11', '0', '', '1', '2024-12-20 15:15:40', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','11','11','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 91 where clientid = 10431;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1051, 830, 830
                    , 830, 830, 830, 830
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,830, 807, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1051, sellCostBuyPrice =sellCostBuyPrice+830
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+830, sellCostMeanBuyPrice = sellCostMeanBuyPrice+830
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+830, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+830
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+830
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+830
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+807
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10431, '2024-12-20', 1051, 830, 830
                    , 830, 830, 830, 830
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,830, 807, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1051, sellCostBuyPrice =sellCostBuyPrice+830
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+830, sellCostMeanBuyPrice = sellCostMeanBuyPrice+830
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+830, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+830
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+830
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+830
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+807
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1051, 830, 830
                    , 830, 830, 830, 830, 830, 807)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1051, netSellCostBuyPrice = netSellCostBuyPrice+830
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+830
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+830
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+830
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+830
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+830
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+830
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+807;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067656d004bcad and sellbillId = 150399 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:45:41";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:15:41", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:15:41', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:47:09";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:17:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:17:09', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247929
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1207,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 15:17:09', userid = '2' WHERE clientid = '1207';
UPDATE client SET  inUse = 0 where clientid = 1207;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1207','3172.00','3172','1','ايصال تحصيل (( قبض من عميل ))','247929', '0', '2024-12-20 15:15:23', '2', 'clientPayedDeptController.php', '   ', '3172', '0', null, '0', null, null,'', '-1','1','1','3172','1','','3637','0');
UPDATE save SET  savecurrentvalue = '125345.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('122173.50','3172', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247930', '125345.5', '2024-12-20 15:17:09', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '3172', '3172', '2024-12-20', '2', '0', '0', '2024-12-20 15:17:09','اضافة ايصال سداد للعميل محل روني D16','1','0','0','0','247930','clientPayedDeptController.php?do=show&id=247930');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122298', '-1', '3172', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '3172', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122298', '-1', '3172', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-3172', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '1207', clientdebtchangebefore = '3172.000', clientdebtchangeamount = '3172.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247929', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 15:15:23', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '3172.00',discount='', reciptid='0', dailyentryid = '122298',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='3172',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247930';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247929 -clientdebtchangeId = 247930
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:47:10";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:17:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:17:10', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:48:27";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 15:18:27", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:18:27', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:48:49";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 15:18:49", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:18:49', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:48:56";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:18:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:18:56', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:49:10";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:19:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:19:10', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:49:38";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:19:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 15:19:38', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:51:12";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:21:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:21:12', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:54:06";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:24:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 15:24:06', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=add');
BEGIN;
CALL supplierInUse(228,@supplierdebt,@suppliername,@dailyentryid,@treeIdis);
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('228', '24385.00', '3000', '1', 'ايصال دفع لمورد', '1', '21385', '2024-12-20 15:19:38', '104', 'supplierPayedDeptController.php', '', '0','1', '-1','1','1','3000','1','0','0','0','410');
UPDATE supplierdebtchange SET supplierid = '228', supplierdebtchangebefore = '24385.00', supplierdebtchangeamount = '3000', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '21385', supplierdebtchangedate = '2024-12-20 15:19:38', userid = '104', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='3000',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='24385',debtchangamountInSupplierCurrency='21385',debtchangafterInSupplierCurrency='21385', paySerialNo='410' WHERE supplierdebtchangeid = '26845';
UPDATE supplier SET  suppliercurrentDebt = '21385',suppliercurrentDebtInCurrency= '21385' , userid = '104', supplierdate = '2024-12-20 15:24:06'   WHERE supplierid = '228';
UPDATE supplier SET  inUse = 0 where supplierid = 228;
UPDATE save SET  savecurrentvalue = '22510',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('25510.00','3000', '1', '1', 'ايصال دفع لمورد', '26845', '22510', '2024-12-20 15:24:06', '104',  'supplierPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '3000', '3000', '2024-12-20', '104', '0', '0', '2024-12-20 15:24:06','ايصال دفع لمورد ( عادل كيكو اسكندريه ) ','1','0','-1','0','26845','supplierReportsController.php?do=show&id=26845');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122299', '-1', '3000', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '3000', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122299', '-1', '3000', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-3000', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE supplierdebtchange SET supplierid = '228', supplierdebtchangebefore = '24385.00', supplierdebtchangeamount = '3000.00', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '21385.00', supplierdebtchangedate = '2024-12-20 15:19:38', userid = '104', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '122299',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='3000',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='24385',debtchangamountInSupplierCurrency='21385',debtchangafterInSupplierCurrency='21385', paySerialNo='410' WHERE supplierdebtchangeid = '26845';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:54:07";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:24:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 15:24:07', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:54:08";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:24:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 15:24:08', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:54:09";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:24:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 15:24:09', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:55:05";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 15:25:05", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:25:05', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067656eb95f520
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7954,@clientdebt,@clientname,@treeIdis);
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 15:18:49', '067656eb95f520', '7954', '0.00', '-810', '0', '1', '810', '810', '0', '-810', '1', '2024-12-20 15:25:05', '', '101', '0', 'ياسمين نصار W229','2', '1', '5', '83', 'ياسمين نصار W229', '1', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '-810', userid = '101' WHERE clientid = '7954';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7954','0.00','810','1','اضافة فاتورة مردوات مبيعات','16850', '-810', '2024-12-20 15:25:05', '101', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '810', '0', null, '0', null, null,'', '0','1','1','810','1','2024-12-20 15:18:49','0','0');
UPDATE client SET  inUse = 0 where clientid = 7954;
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('730.00', '07143', '16850', '5', '16205', '1', '810', '810', '0', '', '1', '0', '16205', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','810','810','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 730.00 , meanbuyprice = 730.00, lastbuyprice_withDiscount = 730.00, meanbuyprice_withDiscount = 730.00
        , lastbuyprice_withTax = 730, meanbuyprice_withTax = 730, lastbuyprice_withDiscountAndTax = 730
                where returnsellbilldetailid = 22040;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16205, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 810, 730, 730, 730
                    , 730, 730, 730, 0, 1, 0, 0, 730, 730)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+810, returnSellCostBuyPrice = returnSellCostBuyPrice+730, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+730
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+730, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+730
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+730
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+730
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+730
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+730
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 810, 730, 730, 730
                    , 730, 730, 730, 0, 0, 730, 730)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+810, returnSellCostBuyPrice = returnSellCostBuyPrice+730, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+730
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+730, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+730
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+730
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+730
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+730
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+730;
UPDATE storedetail SET  productquantity = '59', userid = '101', storedetaildate = '2024-12-20 15:25:05' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '0', '16850', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '58', '59', '101', '2024-12-20 15:25:05','0','0');
UPDATE client SET  delegateid = 83 where clientid = 7954;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 810, 730, 730, 730
                    , 730, 730, 730 ,0, 0, 730, 730)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+810, returnSellCostBuyPrice = returnSellCostBuyPrice+730, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+730
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+730, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+730
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+730
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+730
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+730
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+730;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7954, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 810, 730, 730, 730
                    , 730, 730, 730 ,0, 0, 730, 730)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+810, returnSellCostBuyPrice = returnSellCostBuyPrice+730, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+730
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+730, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+730
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+730
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+730
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+730
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+730;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -810, -730, -730
                    , -730, -730, -730, -730, -730, -730)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-810, netSellCostBuyPrice = netSellCostBuyPrice+-730
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-730
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-730
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-730
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-730
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-730
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-730
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-730;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067656eb95f520 and sellbillId = 16850 and returnsellbillId = 16850
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:55:05";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 15:25:05", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:25:05', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:55:07";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:25:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:25:07', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:56:58";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:26:58", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:26:58', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067656dfd48a52
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7003,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:15:41', '067656dfd48a52', '7003', '4.00', '1095', '0', '1', '1091.00', '1091', '0', '1091', '1', '2024-12-20 15:26:58', '', '75', '0', 'نجلاء السيد B10', '2', '1', '3', '98', 'نجلاء السيد B10', '4' ,'0','','','','','-1','0','0','0','0','0','1091','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1095', userid = '75' WHERE clientid = '7003';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7003','4.00','1091','0','اضافة فاتورة مبيعات','150400', '1095', '2024-12-20 15:26:58', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1091', '0', null, '0', null, null,'', '0','1','1','1091','1','2024-12-20 15:15:41','0','0');
UPDATE client SET  inUse = 0 where clientid = 7003;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35674;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('700','H1337', '150400', '14', '15406', '1', '810', '810', '0', '', '1', '2024-12-20 15:26:58', '15406', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35674-1,','1','1','0','0','810','810','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 700.00 , meanbuyprice = 700.00, lastbuyprice_withDiscount = 700.00, meanbuyprice_withDiscount = 700.00
        , lastbuyprice_withTax = 700, meanbuyprice_withTax = 621, lastbuyprice_withDiscountAndTax = 700
                where sellbilldetailid = 549505;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15406, '2024-12-20', 810, 700, 700
                    , 700, 700, 700, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 700, 621, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+621
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 810, 700, 700
                    , 700, 700, 700, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0, 700, 621, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+621
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '75', storedetaildate = '2024-12-20 15:26:58' WHERE storedetailid = '15405';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15406', '1', '1', '1', '150400', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-20 15:26:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36335;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('180','H1658', '150400', '14', '16424', '1', '250', '250', '0', '', '1', '2024-12-20 15:26:58', '16424', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36335-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
        , lastbuyprice_withTax = 180, meanbuyprice_withTax = 180, lastbuyprice_withDiscountAndTax = 180
                where sellbilldetailid = 549506;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16424, '2024-12-20', 250, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+180
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 250, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+180
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '75', storedetaildate = '2024-12-20 15:26:58' WHERE storedetailid = '16423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16424', '1', '1', '1', '150400', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-20 15:26:58','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150400', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 15:26:59', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150400', '17', '10291', '1', '11', '11', '0', '', '1', '2024-12-20 15:26:59', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','11','11','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 98 where clientid = 7003;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1091, 880, 880
                    , 880, 880, 880, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,880, 801, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1091, sellCostBuyPrice =sellCostBuyPrice+880
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+880, sellCostMeanBuyPrice = sellCostMeanBuyPrice+880
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+880, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+880
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+880
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+880
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+801
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7003, '2024-12-20', 1091, 880, 880
                    , 880, 880, 880, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,880, 801, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1091, sellCostBuyPrice =sellCostBuyPrice+880
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+880, sellCostMeanBuyPrice = sellCostMeanBuyPrice+880
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+880, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+880
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+880
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+880
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+801
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1091, 880, 880
                    , 880, 880, 880, 880, 880, 801)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1091, netSellCostBuyPrice = netSellCostBuyPrice+880
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+880
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+880
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+880
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+880
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+880
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+880
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+801;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067656dfd48a52 and sellbillId = 150400 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:56:59";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:26:59", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:26:59', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:57:33";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:27:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:27:33', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067656f4895010
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:21:12', '067656f4895010', '1', '0.00', '0', '0', '1', '290.00', '290', '290', '0', '1', '2024-12-20 15:27:33', '', '104', '0', 'نقدي', '1', '0', '3', '8', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','290','0','','0','0','290','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150401', '0', '2024-12-20 15:27:33', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '290', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 15:21:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36358;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06603', '150401', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-20 15:27:33', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36358-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 226.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 226.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 227, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549509;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15038, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '46', userid = '104', storedetaildate = '2024-12-20 15:27:33' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '150401', 'اضافة فاتورة مبيعات', 'sellbillController.php', '47', '46', '104', '2024-12-20 15:27:33','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22800',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('22510','290', '0', '1', 'اضافة فاتورة مبيعات', '150401', '22800', '2024-12-20 15:27:33', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 8 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 290, 225, 225
                    , 226, 225, 226, 235.95, 225, 227)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+290, netSellCostBuyPrice = netSellCostBuyPrice+225
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+225
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+226
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+225
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+226
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+235.95
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+225
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+227;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067656f4895010 and sellbillId = 150401 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 11:57:34";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:27:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:27:34', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:01:49";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 15:31:49", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:31:49', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067656aec6dc92
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(525,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:02:36', '067656aec6dc92', '525', '0.00', '970', '0', '1', '970.00', '970', '0', '970', '1', '2024-12-20 15:31:49', '', '101', '0', 'عبير النصر K140', '2', '1', '3', '79', 'عبير النصر K140', '4' ,'0','','','','','-1','0','0','0','0','0','970','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '970', userid = '101' WHERE clientid = '525';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('525','0.00','970','0','اضافة فاتورة مبيعات','150402', '970', '2024-12-20 15:31:49', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '970', '0', null, '0', null, null,'', '0','1','1','970','1','2024-12-20 15:02:36','0','0');
UPDATE client SET  inUse = 0 where clientid = 525;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35732;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('480','H1596', '150402', '14', '16219', '1', '580', '580', '0', '', '1', '2024-12-20 15:31:50', '16219', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35732-1,','1','1','0','0','580','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 480.00 , meanbuyprice = 480.00, lastbuyprice_withDiscount = 480.00, meanbuyprice_withDiscount = 480.00
        , lastbuyprice_withTax = 480, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 480
                where sellbilldetailid = 549510;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16219, '2024-12-20', 580, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 580, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '101', storedetaildate = '2024-12-20 15:31:50' WHERE storedetailid = '16218';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16219', '1', '1', '1', '150402', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '101', '2024-12-20 15:31:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36336;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','23664', '150402', '5', '15673', '1', '360', '360', '0', '', '1', '2024-12-20 15:31:50', '15673', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36336-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 295.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 295.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 549511;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15673, '2024-12-20', 360, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '30', userid = '101', storedetaildate = '2024-12-20 15:31:50' WHERE storedetailid = '15672';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15673', '1', '1', '1', '150402', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31', '30', '101', '2024-12-20 15:31:50','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150402', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 15:31:50', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150402', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-20 15:31:50', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','10','10','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 79 where clientid = 525;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 970, 775, 775
                    , 775, 775, 775, 775
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,775, 775, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+970, sellCostBuyPrice =sellCostBuyPrice+775
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+775, sellCostMeanBuyPrice = sellCostMeanBuyPrice+775
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+775, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+775
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+775
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+775
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+775
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (525, '2024-12-20', 970, 775, 775
                    , 775, 775, 775, 775
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,775, 775, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+970, sellCostBuyPrice =sellCostBuyPrice+775
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+775, sellCostMeanBuyPrice = sellCostMeanBuyPrice+775
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+775, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+775
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+775
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+775
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+775
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 970, 775, 775
                    , 775, 775, 775, 775, 775, 775)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+970, netSellCostBuyPrice = netSellCostBuyPrice+775
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+775
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+775
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+775
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+775
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+775
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+775
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+775;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067656aec6dc92 and sellbillId = 150402 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:01:50";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 15:31:50", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:31:50', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:02:28";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 15:32:28", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:32:28', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:03:00";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 15:33:00", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:33:00', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150402');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:03:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:33:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:33:38', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247931
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6650,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '40' , clientdate = '2024-12-20 15:33:38', userid = '2' WHERE clientid = '6650';
UPDATE client SET  inUse = 0 where clientid = 6650;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6650','1000.00','960','1','ايصال تحصيل (( قبض من عميل ))','247931', '40', '2024-12-20 15:17:10', '2', 'clientPayedDeptController.php', '   ', '960', '0', null, '0', null, null,'', '-1','1','1','960','1','','3638','0');
UPDATE save SET  savecurrentvalue = '126305.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('125345.50','960', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247935', '126305.5', '2024-12-20 15:33:38', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '960', '960', '2024-12-20', '2', '0', '0', '2024-12-20 15:33:39','اضافة ايصال سداد للعميل ريم غانم k64','1','0','0','0','247935','clientPayedDeptController.php?do=show&id=247935');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122300', '-1', '960', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '960', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122300', '-1', '960', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-960', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '6650', clientdebtchangebefore = '1000.000', clientdebtchangeamount = '960.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247931', clientdebtchangeafter = '40.000', clientdebtchangedate = '2024-12-20 15:17:10', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '960.00',discount='', reciptid='0', dailyentryid = '122300',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='960',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247935';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247931 -clientdebtchangeId = 247935
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:03:39";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:33:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:33:39', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:05:18";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:35:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:35:18', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247936
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6413,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '20' , clientdate = '2024-12-20 15:35:18', userid = '2' WHERE clientid = '6413';
UPDATE client SET  inUse = 0 where clientid = 6413;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6413','444.00','424','1','ايصال تحصيل (( قبض من عميل ))','247936', '20', '2024-12-20 15:33:39', '2', 'clientPayedDeptController.php', '   ', '424', '0', null, '0', null, null,'', '-1','1','1','424','1','','3639','0');
UPDATE save SET  savecurrentvalue = '126729.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('126305.50','424', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247936', '126729.5', '2024-12-20 15:35:18', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '424', '424', '2024-12-20', '2', '0', '0', '2024-12-20 15:35:18','اضافة ايصال سداد للعميل فاطمه عبد العزيز73','1','0','0','0','247936','clientPayedDeptController.php?do=show&id=247936');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122301', '-1', '424', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '424', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122301', '-1', '424', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-424', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '6413', clientdebtchangebefore = '444.000', clientdebtchangeamount = '424.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247936', clientdebtchangeafter = '20.000', clientdebtchangedate = '2024-12-20 15:33:39', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '424.00',discount='', reciptid='0', dailyentryid = '122301',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='424',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247936';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247936 -clientdebtchangeId = 247936
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:05:19";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:35:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:35:19', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:05:55";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:35:55", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:35:55', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676570a3c9d72
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9811,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:26:59', '0676570a3c9d72', '9811', '0.00', '222', '0', '1', '222.00', '222', '0', '222', '1', '2024-12-20 15:35:55', '', '75', '0', 'شروق الطبجي 41', '2', '1', '3', '87', 'شروق الطبجي 41', '3' ,'0','','','','','-1','0','0','0','0','0','222','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '222', userid = '75' WHERE clientid = '9811';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9811','0.00','222','0','اضافة فاتورة مبيعات','150403', '222', '2024-12-20 15:35:55', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '222', '0', null, '0', null, null,'', '0','1','1','222','1','2024-12-20 15:26:59','0','0');
UPDATE client SET  inUse = 0 where clientid = 9811;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','07293', '150403', '5', '16434', '1', '200', '200', '0', '', '1', '2024-12-20 15:35:55', '16434', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549514;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16434, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '75', storedetaildate = '2024-12-20 15:35:55' WHERE storedetailid = '16433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16434', '1', '1', '1', '150403', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '75', '2024-12-20 15:35:55','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150403', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 15:35:55', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150403', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-20 15:35:55', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','2','2','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 87 where clientid = 9811;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 222, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+222, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9811, '2024-12-20', 222, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+222, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 222, 145, 145
                    , 145, 145, 145, 145, 145, 145)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+222, netSellCostBuyPrice = netSellCostBuyPrice+145
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+145
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+145
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+145
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+145
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+145
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+145
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+145;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676570a3c9d72 and sellbillId = 150403 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:05:56";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:35:56", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:35:56', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:06:11";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:36:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:36:11', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676570c69afff
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:27:34', '0676570c69afff', '1', '0.00', '0', '0', '1', '470.00', '470', '470', '0', '1', '2024-12-20 15:36:12', '', '104', '0', 'نقدي', '1', '0', '3', '26', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','470','0','','0','0','470','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150404', '0', '2024-12-20 15:36:12', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '470', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 15:27:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36282;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('410','R3335', '150404', '1', '16410', '1', '470', '470', '0', '', '1', '2024-12-20 15:36:12', '16410', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36282-1,','1','1','0','0','470','470','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
        , lastbuyprice_withTax = 410, meanbuyprice_withTax = 410, lastbuyprice_withDiscountAndTax = 410
                where sellbilldetailid = 549517;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16410, '2024-12-20', 470, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '104', storedetaildate = '2024-12-20 15:36:12' WHERE storedetailid = '16409';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16410', '1', '1', '1', '150404', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-20 15:36:12','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '23270',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('22800','470', '0', '1', 'اضافة فاتورة مبيعات', '150404', '23270', '2024-12-20 15:36:12', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 26 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 470, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 470, 410, 410
                    , 410, 410, 410, 410, 410, 410)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+470, netSellCostBuyPrice = netSellCostBuyPrice+410
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+410
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+410
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+410
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+410
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+410
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+410
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+410;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676570c69afff and sellbillId = 150404 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:06:12";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:36:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:36:12', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:07:41";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:37:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:37:41', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676572cceb67c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:36:12', '0676572cceb67c', '1', '0.00', '0', '0', '1', '745.00', '745', '745', '0', '1', '2024-12-20 15:37:41', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','745','0','','0','0','745','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150405', '0', '2024-12-20 15:37:41', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '745', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 15:36:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36391;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','R3329', '150405', '1', '16322', '1', '365', '365', '0', '', '1', '2024-12-20 15:37:42', '16322', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36391-1,','1','1','0','0','365','365','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 295.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 295.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 549518;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16322, '2024-12-20', 365, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+365, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 365, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+365, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '27', userid = '104', storedetaildate = '2024-12-20 15:37:42' WHERE storedetailid = '16321';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16322', '1', '1', '1', '150405', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '27', '104', '2024-12-20 15:37:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36319;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('330','07291', '150405', '5', '16416', '1', '380', '380', '0', '', '1', '2024-12-20 15:37:42', '16416', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36319-1,','1','1','0','0','380','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
        , lastbuyprice_withTax = 330, meanbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 330
                where sellbilldetailid = 549519;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16416, '2024-12-20', 380, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+330
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 380, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+330
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-20 15:37:42' WHERE storedetailid = '16415';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16416', '1', '1', '1', '150405', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-20 15:37:42','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24015',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('23270','745', '0', '1', 'اضافة فاتورة مبيعات', '150405', '24015', '2024-12-20 15:37:42', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 745, 625, 625
                    , 625, 625, 625, 625
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,625, 625, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+745, sellCostBuyPrice =sellCostBuyPrice+625
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+625, sellCostMeanBuyPrice = sellCostMeanBuyPrice+625
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+625, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+625
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+625
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+625
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+625
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 745, 625, 625
                    , 625, 625, 625, 625
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,625, 625, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+745, sellCostBuyPrice =sellCostBuyPrice+625
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+625, sellCostMeanBuyPrice = sellCostMeanBuyPrice+625
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+625, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+625
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+625
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+625
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+625
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 745, 625, 625
                    , 625, 625, 625, 625, 625, 625)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+745, netSellCostBuyPrice = netSellCostBuyPrice+625
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+625
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+625
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+625
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+625
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+625
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+625
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+625;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676572cceb67c and sellbillId = 150405 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:07:42";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:37:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:37:42', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:12:26";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:42:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 15:42:26', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('شيماء رمضان 25' , '', '', '0115288038', '0', '', '0', '2024-12-20 15:42:57', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10770', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10770','0','0','0','إضافة عميل جديد','10770', '0', '2024-12-20 15:42:57', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('شيماء رمضان 25', 'شيماء رمضان 25', 'شيماء رمضان 25', 'شيماء رمضان 25', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-20 15:42:58');
UPDATE client SET clientname = 'شيماء رمضان 25', clientaddress = '', clientphone = '', clientmobile = '0115288038', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '75'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12611',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10770';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:14:30";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:44:30", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:44:30', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676572bcb194f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10770,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:35:56', '0676572bcb194f', '10770', '0.00', '2677', '0', '1', '2677.00', '2677', '0', '2677', '1', '2024-12-20 15:44:30', '', '75', '0', 'شيماء رمضان 25', '2', '1', '3', '78', 'شيماء رمضان 25', '6' ,'0','','','','','-1','0','0','0','0','0','2677','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2677', userid = '75' WHERE clientid = '10770';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10770','0.00','2677','0','اضافة فاتورة مبيعات','150406', '2677', '2024-12-20 15:44:30', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2677', '0', null, '0', null, null,'', '0','1','1','2677','1','2024-12-20 15:35:56','0','0');
UPDATE client SET  inUse = 0 where clientid = 10770;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 22659;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('530','H1210', '150406', '16', '10333', '1', '560', '560', '0', '', '1', '2024-12-20 15:44:30', '10333', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','22659-1,','1','1','0','0','560','560','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 530.00 , meanbuyprice = 530.00, lastbuyprice_withDiscount = 530.00, meanbuyprice_withDiscount = 530.00
        
                where sellbilldetailid = 549520;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10333, '2024-12-20', 560, 530, 530
                    , 530, 530, 530, 530
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+560, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+530
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 560, 530, 530
                    , 530, 530, 530, 530
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+560, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+530
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '18', userid = '75', storedetaildate = '2024-12-20 15:44:30' WHERE storedetailid = '10332';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10333', '1', '1', '1', '150406', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '75', '2024-12-20 15:44:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36006;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('650','H1601', '150406', '14', '16226', '1', '800', '800', '0', '', '1', '2024-12-20 15:44:30', '16226', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36006-1,','1','1','0','0','800','800','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 650.00 , meanbuyprice = 650.00, lastbuyprice_withDiscount = 650.00, meanbuyprice_withDiscount = 650.00
        , lastbuyprice_withTax = 650, lastbuyprice_withDiscountAndTax = 650
                where sellbilldetailid = 549521;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16226, '2024-12-20', 800, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 650, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 800, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0, 650, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-2', userid = '75', storedetaildate = '2024-12-20 15:44:30' WHERE storedetailid = '16225';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16226', '1', '1', '1', '150406', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-1', '-2', '75', '2024-12-20 15:44:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36159;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('585','H1644', '150406', '14', '16388', '1', '670', '670', '0', '', '1', '2024-12-20 15:44:30', '16388', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36159-1,','1','1','0','0','670','670','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 585.00 , meanbuyprice = 585.00, lastbuyprice_withDiscount = 585.00, meanbuyprice_withDiscount = 585.00
        , lastbuyprice_withTax = 585, meanbuyprice_withTax = 585, lastbuyprice_withDiscountAndTax = 585
                where sellbilldetailid = 549522;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16388, '2024-12-20', 670, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+670, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+585
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+585
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 670, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0, 585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+670, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+585
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+585
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '75', storedetaildate = '2024-12-20 15:44:30' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '1', '1', '150406', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '75', '2024-12-20 15:44:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35883;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('550','07227', '150406', '5', '16282', '1', '600', '600', '0', '', '1', '2024-12-20 15:44:30', '16282', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35883-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 550.00 , meanbuyprice = 550.00, lastbuyprice_withDiscount = 550.00, meanbuyprice_withDiscount = 550.00
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 437, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 549523;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16282, '2024-12-20', 600, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 550, 437, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+437
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 437, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+437
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '75', storedetaildate = '2024-12-20 15:44:30' WHERE storedetailid = '16281';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16282', '1', '1', '1', '150406', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-20 15:44:30','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150406', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 15:44:30', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150406', '17', '10291', '1', '27', '27', '0', '', '1', '2024-12-20 15:44:30', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','27','27','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 78 where clientid = 10770;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2677, 2315, 2315
                    , 2315, 2315, 2315, 2315
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1785, 1022, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2677, sellCostBuyPrice =sellCostBuyPrice+2315
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2315, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2315
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2315, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2315
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2315
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1785
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1022
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10770, '2024-12-20', 2677, 2315, 2315
                    , 2315, 2315, 2315, 2315
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1785, 1022, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2677, sellCostBuyPrice =sellCostBuyPrice+2315
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2315, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2315
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2315, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2315
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2315
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1785
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1022
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2677, 2315, 2315
                    , 2315, 2315, 2315, 2315, 1785, 1022)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2677, netSellCostBuyPrice = netSellCostBuyPrice+2315
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2315
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2315
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2315
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2315
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2315
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1785
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1022;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676572bcb194f and sellbillId = 150406 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:14:31";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:44:31", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:44:31', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:19:35";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:49:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:49:35', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:20:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:50:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:50:46', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=4');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:21:20";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:51:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:51:20', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676576367de9c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbillandrutern (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, sellbillprice, returnsellbillprice, tempclientName,sellQuantity, returnsellQuantity, tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,pricetype,currencyId,totalprodiscount,sellbillno,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue) VALUES ('2024-12-20 15:50:46', '0676576367de9c', '1', '0.00', '0', '0', '1', '95.00', '95', '95', '0', '1', '2024-12-20 15:51:20', '', '104', '0', 'نقدي', '1', '0', '4', '0', '280', '185', 'نقدي', '1', '1', '0', '', '', '','','-1','0','0','0','','0','95','0','0','0','0','0','0','0','1','-1','0','1','0','','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات ومردودات','124', '0', '2024-12-20 15:51:20', '104', 'sellbillandruternController.php', 'اضافة فاتورة مبيعات ومردودات', '95', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 15:50:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35992;
INSERT INTO sellandruternbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, selltype, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,buyPricesHistoryBookIdQuantity,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,categorydiscount,lastbuyprice_withDiscountAndTax) VALUES ('230','07252', '124', '5', '16337', '1', '280', '280.00', '0', '', '0', '2024-12-20 15:51:20', '0', '16337', '0.00', '-1', '1','0','','','0','0','0','0','0','0','35992-1,','1','1','','0','0','280','280','0','','','0');
UPDATE sellandruternbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where sellbilldetailid = 318;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16337, '2024-12-20', 280, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 280, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '31', userid = '104', storedetaildate = '2024-12-20 15:51:20' WHERE storedetailid = '16336';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16337', '1', '1', '1', '124', 'فاتوره مبيعات ومردودات', 'sellbillandruternController.php', '32', '31', '104', '2024-12-20 15:51:20','0','0');
INSERT INTO sellandruternbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, selltype, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,buyPricesHistoryBookIdQuantity,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,categorydiscount,lastbuyprice_withDiscountAndTax) VALUES ('145.00','07093', '124', '5', '16084', '1', '185', '185', '0', '', '0', '2024-12-20 15:51:20', '1', '16084', '0.00', '-1', '1','0','','','0','0','0','0','0','0','','1','1','','0','0','185','185','0','','','0');
UPDATE sellandruternbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 319;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16084, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 185, 145, 145, 145
                    , 145, 145, 145, 0, 1, 0, 0, 145, 145)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+185, returnSellCostBuyPrice = returnSellCostBuyPrice+145, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+145
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+145, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+145
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+145
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+145
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+145
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+145
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 185, 145, 145, 145
                    , 145, 145, 145, 0, 0, 145, 145)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+185, returnSellCostBuyPrice = returnSellCostBuyPrice+145, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+145
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+145, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+145
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+145
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+145
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+145
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+145;
UPDATE storedetail SET  productquantity = '2', userid = '104', storedetaildate = '2024-12-20 15:51:20' WHERE storedetailid = '16083';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16084', '1', '1', '0', '124', 'اضافة فاتورة مردودات مبيعات', 'sellbillandruternController.php', '1', '2', '104', '2024-12-20 15:51:20','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24110',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24015','95', '0', '1', 'اضافة فاتورة مبيعات ومردودات', '124', '24110', '2024-12-20 15:51:20', '104',  'sellbillandruternController.php','1','','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 280, 230, 230
                    , 230, 230, 230, 230
                    , 185, 145, 145, 145
                    , 145, 145, 145 ,230, 230, 145, 145)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+185, returnSellCostBuyPrice = returnSellCostBuyPrice+145, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+145
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+145, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+145
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+145
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+145
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+145
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+145;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 280, 230, 230
                    , 230, 230, 230, 230
                    , 185, 145, 145, 145
                    , 145, 145, 145 ,230, 230, 145, 145)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+185, returnSellCostBuyPrice = returnSellCostBuyPrice+145, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+145
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+145, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+145
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+145
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+145
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+145
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+145;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 95, 85, 85
                    , 85, 85, 85, 85, 85, 85)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+95, netSellCostBuyPrice = netSellCostBuyPrice+85
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+85
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+85
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+85
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+85
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+85
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+85
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+85;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676576367de9c and sellbillId = 124 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:21:20";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:51:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-20 15:51:20', '104', 'editprint', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=editprint&id=124');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:21:27";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:51:27", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-20 15:51:27', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:21:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:51:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:51:28', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:21:46";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:51:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-20 15:51:46', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =1104
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1104,@clientdebt,@clientname,@treeIdis);
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1104','-1024.00','1024','0','تسوية عجز عميل بالزيادة','-1', '0', '2024-12-20 15:51:47', '2', 'clientDeficitController.php', '', '1024', '0', null, '0', null, null,'', '0','1','1','1024','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20', userid = '2' WHERE clientid = '1104';
UPDATE client SET  inUse = 0 where clientid = 1104;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =1104 ,id=247943
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:21:47";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:51:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-20 15:51:47', '2', 'sucess', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:21:49";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:51:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-20 15:51:49', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:21:59";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:51:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:51:59', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676576611c844
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:51:29', '0676576611c844', '1', '0.00', '0', '0', '1', '550.00', '550', '550', '0', '1', '2024-12-20 15:51:59', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','550','0','','0','0','550','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150407', '0', '2024-12-20 15:51:59', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '550', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 15:51:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36023;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('450','H1638', '150407', '14', '16339', '1', '550', '550', '0', '', '1', '2024-12-20 15:52:00', '16339', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36023-1,','1','1','0','0','550','550','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
        , lastbuyprice_withTax = 450, meanbuyprice_withTax = 450, lastbuyprice_withDiscountAndTax = 450
                where sellbilldetailid = 549526;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16339, '2024-12-20', 550, 450, 450
                    , 450, 450, 450, 450
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 450, 450, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+450
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+450
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 550, 450, 450
                    , 450, 450, 450, 450
                    , 0, 0, 0, 0
                    , 0, 0, 0, 450, 450, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+450
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+450
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-20 15:52:00' WHERE storedetailid = '16338';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16339', '1', '1', '1', '150407', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-20 15:52:00','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24660',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24110','550', '0', '1', 'اضافة فاتورة مبيعات', '150407', '24660', '2024-12-20 15:52:00', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 550, 450, 450
                    , 450, 450, 450, 450
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,450, 450, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+450
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+450
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 550, 450, 450
                    , 450, 450, 450, 450
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,450, 450, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+450
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+450
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 550, 450, 450
                    , 450, 450, 450, 450, 450, 450)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+550, netSellCostBuyPrice = netSellCostBuyPrice+450
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+450
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+450
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+450
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+450
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+450
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+450
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+450;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676576611c844 and sellbillId = 150407 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:22:00";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:52:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:52:00', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:22:54";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:52:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:52:54', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657680d1f3b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:52:00', '067657680d1f3b', '1', '0.00', '0', '0', '1', '280.00', '280', '280', '0', '1', '2024-12-20 15:52:54', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','280','0','','0','0','280','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150408', '0', '2024-12-20 15:52:54', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '280', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 15:52:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35992;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('230','07252', '150408', '5', '16337', '1', '280', '280', '0', '', '1', '2024-12-20 15:52:54', '16337', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35992-1,','1','1','0','0','280','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where sellbilldetailid = 549527;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16337, '2024-12-20', 280, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 280, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '30', userid = '104', storedetaildate = '2024-12-20 15:52:54' WHERE storedetailid = '16336';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16337', '1', '1', '1', '150408', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31', '30', '104', '2024-12-20 15:52:54','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24940',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24660','280', '0', '1', 'اضافة فاتورة مبيعات', '150408', '24940', '2024-12-20 15:52:54', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 280, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 280, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 280, 230, 230
                    , 230, 230, 230, 230, 230, 230)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+280, netSellCostBuyPrice = netSellCostBuyPrice+230
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+230
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+230
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+230
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+230
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+230
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+230
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+230;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657680d1f3b and sellbillId = 150408 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:22:55";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:52:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:52:55', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:23:10";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:53:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:53:10', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247937
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9659,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '9' , clientdate = '2024-12-20 15:53:10', userid = '2' WHERE clientid = '9659';
UPDATE client SET  inUse = 0 where clientid = 9659;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9659','1929.00','1920','1','ايصال تحصيل (( قبض من عميل ))','247937', '9', '2024-12-20 15:35:19', '2', 'clientPayedDeptController.php', '   ', '1920', '0', null, '0', null, null,'', '-1','1','1','1920','1','','3640','0');
UPDATE save SET  savecurrentvalue = '128649.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('126729.50','1920', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247946', '128649.5', '2024-12-20 15:53:10', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('مروة عبد السميع 12', 'مروة عبد السميع 12', 'مروة عبد السميع 12', 'مروة عبد السميع 12', '58', '0', '9.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 15:53:10');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1920', '1920', '2024-12-20', '2', '0', '0', '2024-12-20 15:53:10','اضافة ايصال سداد للعميل مروة عبد السميع 12','1','0','0','0','247946','clientPayedDeptController.php?do=show&id=247946');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122302', '-1', '1920', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1920', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122302', '12612', '1920', '','0');
UPDATE accountstree SET name = 'مروة عبد السميع 12', customName = 'مروة عبد السميع 12', customNameEn = 'مروة عبد السميع 12', nameEn = 'مروة عبد السميع 12', parent = '58', accountNature = '0', theValue = '-1911', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 15:53:10' WHERE id = '12612';
UPDATE clientdebtchange SET clientid = '9659', clientdebtchangebefore = '1929.000', clientdebtchangeamount = '1920.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247937', clientdebtchangeafter = '9.000', clientdebtchangedate = '2024-12-20 15:35:19', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1920.00',discount='', reciptid='0', dailyentryid = '122302',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1920',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247946';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247937 -clientdebtchangeId = 247946
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:23:10";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:53:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:53:10', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:23:33";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:53:33", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:53:33', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247947
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5737,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '442' , clientdate = '2024-12-20 15:53:33', userid = '2' WHERE clientid = '5737';
UPDATE client SET  inUse = 0 where clientid = 5737;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5737','642.00','200','1','ايصال تحصيل (( قبض من عميل ))','247947', '442', '2024-12-20 15:53:11', '2', 'clientPayedDeptController.php', '   ', '200', '0', null, '0', null, null,'', '-1','1','1','200','1','','3641','0');
UPDATE save SET  savecurrentvalue = '128849.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('128649.50','200', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247947', '128849.5', '2024-12-20 15:53:33', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '200', '200', '2024-12-20', '2', '0', '0', '2024-12-20 15:53:33','اضافة ايصال سداد للعميل مريم حافظ 41','1','0','0','0','247947','clientPayedDeptController.php?do=show&id=247947');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122303', '-1', '200', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '200', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122303', '-1', '200', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-200', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '5737', clientdebtchangebefore = '642.000', clientdebtchangeamount = '200.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247947', clientdebtchangeafter = '442.000', clientdebtchangedate = '2024-12-20 15:53:11', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '200.00',discount='', reciptid='0', dailyentryid = '122303',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='200',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247947';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247947 -clientdebtchangeId = 247947
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:23:34";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:53:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:53:34', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:23:52";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:53:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:53:52', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247948
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5737,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '26' , clientdate = '2024-12-20 15:53:52', userid = '2' WHERE clientid = '5737';
UPDATE client SET  inUse = 0 where clientid = 5737;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5737','442.00','416','1','ايصال تحصيل (( قبض من عميل ))','247948', '26', '2024-12-20 15:53:34', '2', 'clientPayedDeptController.php', '   ', '416', '0', null, '0', null, null,'', '-1','1','1','416','1','','3642','0');
UPDATE save SET  savecurrentvalue = '129265.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('128849.50','416', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247948', '129265.5', '2024-12-20 15:53:52', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '416', '416', '2024-12-20', '2', '0', '0', '2024-12-20 15:53:52','اضافة ايصال سداد للعميل مريم حافظ 41','1','0','0','0','247948','clientPayedDeptController.php?do=show&id=247948');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122304', '-1', '416', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '416', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122304', '-1', '416', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-416', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '5737', clientdebtchangebefore = '442.000', clientdebtchangeamount = '416.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247948', clientdebtchangeafter = '26.000', clientdebtchangedate = '2024-12-20 15:53:34', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '416.00',discount='', reciptid='0', dailyentryid = '122304',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='416',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247948';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247948 -clientdebtchangeId = 247948
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:23:52";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 15:53:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 15:53:52', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:24:08";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:54:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 15:54:08', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:24:10";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:54:10", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:54:10', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676574bf3a258
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2299,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:44:31', '0676574bf3a258', '2299', '0.00', '1773', '0', '1', '1773.00', '1773', '0', '1773', '1', '2024-12-20 15:54:10', '', '75', '0', 'ريم عبد المنعم 14', '2', '1', '3', '83', 'ريم عبد المنعم 14', '9' ,'0','','','','','-1','0','0','0','0','0','1773','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1773', userid = '75' WHERE clientid = '2299';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2299','0.00','1773','0','اضافة فاتورة مبيعات','150409', '1773', '2024-12-20 15:54:10', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1773', '0', null, '0', null, null,'', '0','1','1','1773','1','2024-12-20 15:44:31','0','0');
UPDATE client SET  inUse = 0 where clientid = 2299;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 25712;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('490','05345', '150409', '5', '11665', '1', '510', '510', '0', '', '1', '2024-12-20 15:54:10', '11665', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','25712-1,','1','1','0','0','510','510','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 490.00 , meanbuyprice = 490.00, lastbuyprice_withDiscount = 490.00, meanbuyprice_withDiscount = 490.00
        
                where sellbilldetailid = 549528;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11665, '2024-12-20', 510, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+490, sellCostMeanBuyPrice = sellCostMeanBuyPrice+490
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+490, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+490
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+490
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 510, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+490, sellCostMeanBuyPrice = sellCostMeanBuyPrice+490
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+490, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+490
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+490
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-20 15:54:10' WHERE storedetailid = '11664';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11665', '1', '1', '1', '150409', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-20 15:54:10','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('230','R2682', '150409', '1', '13128', '1', '180', '180', '0', '', '1', '2024-12-20 15:54:10', '13128', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','180','180','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 345.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 345.00
        
                where sellbilldetailid = 549529;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13128, '2024-12-20', 180, 230, 230
                    , 345, 230, 345, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 180, 230, 230
                    , 345, 230, 345, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 15:54:10' WHERE storedetailid = '13127';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13128', '1', '1', '1', '150409', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 15:54:10','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('160','06759', '150409', '5', '15324', '1', '155', '155', '0', '', '1', '2024-12-20 15:54:10', '15324', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 150, lastbuyprice_withDiscountAndTax = 160
                where sellbilldetailid = 549530;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15324, '2024-12-20', 155, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 160, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 160, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '75', storedetaildate = '2024-12-20 15:54:10' WHERE storedetailid = '15323';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15324', '1', '1', '1', '150409', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '75', '2024-12-20 15:54:10','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','06036', '150409', '5', '13503', '1', '185', '185', '0', '', '1', '2024-12-20 15:54:10', '13503', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        
                where sellbilldetailid = 549531;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13503, '2024-12-20', 185, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 185, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-4', userid = '75', storedetaildate = '2024-12-20 15:54:10' WHERE storedetailid = '13502';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13503', '1', '1', '1', '150409', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-3', '-4', '75', '2024-12-20 15:54:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32680;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','R2981', '150409', '1', '14587', '1', '255', '255', '0', '', '1', '2024-12-20 15:54:10', '14587', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32680-1,','1','1','0','0','255','255','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 549532;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14587, '2024-12-20', 255, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 255, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 15:54:10' WHERE storedetailid = '14586';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14587', '1', '1', '1', '150409', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 15:54:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31746;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','R2864', '150409', '1', '14267', '1', '225', '225', '0', '', '1', '2024-12-20 15:54:10', '14267', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31746-1,','1','1','0','0','225','225','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 249.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 249.00
        
                where sellbilldetailid = 549533;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14267, '2024-12-20', 225, 245, 240
                    , 249, 240, 249, 248.57
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+248.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 225, 245, 240
                    , 249, 240, 249, 248.57
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+248.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 15:54:10' WHERE storedetailid = '14266';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14267', '1', '1', '1', '150409', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 15:54:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31865;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','R2875', '150409', '1', '14311', '1', '225', '225', '0', '', '1', '2024-12-20 15:54:10', '14311', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31865-1,','1','1','0','0','225','225','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 549534;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14311, '2024-12-20', 225, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 225, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 15:54:10' WHERE storedetailid = '14310';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14311', '1', '1', '1', '150409', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-20 15:54:10','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150409', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 15:54:10', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150409', '17', '10291', '1', '18', '18', '0', '', '1', '2024-12-20 15:54:10', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','18','18','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 83 where clientid = 2299;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1773, 1975, 1970
                    , 2094, 1970, 2094, 1978.57
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,160, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1773, sellCostBuyPrice =sellCostBuyPrice+1975
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1970, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2094
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1970, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2094
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1978.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2299, '2024-12-20', 1773, 1975, 1970
                    , 2094, 1970, 2094, 1978.57
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,160, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1773, sellCostBuyPrice =sellCostBuyPrice+1975
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1970, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2094
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1970, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2094
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1978.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1773, 1975, 1970
                    , 2094, 1970, 2094, 1978.57, 160, 150)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1773, netSellCostBuyPrice = netSellCostBuyPrice+1975
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1970
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2094
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1970
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2094
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1978.57
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+160
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+150;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676574bf3a258 and sellbillId = 150409 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:24:11";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 15:54:11", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:54:11', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:24:13";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:54:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 15:54:13', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'نفحة', '', '5', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '24935',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24940.00','5', '1', '1', 'إضافة مصروف', '25909', '24935', '2024-12-20 15:54:13', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'نفحة', expensesdetails = '', expensesValue = '5.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25909';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:24:14";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:54:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 15:54:14', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:24:15";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:54:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 15:54:15', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('عروب الزقازيق 52' , '', '', '01022726346', '0', '', '0', '2024-12-20 15:58:00', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10771', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10771','0','0','0','إضافة عميل جديد','10771', '0', '2024-12-20 15:58:00', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('عروب الزقازيق 52', 'عروب الزقازيق 52', 'عروب الزقازيق 52', 'عروب الزقازيق 52', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-20 15:58:00');
UPDATE client SET clientname = 'عروب الزقازيق 52', clientaddress = '', clientphone = '', clientmobile = '01022726346', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '75'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12613',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10771';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:28:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:58:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:58:28', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676576b745294
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:52:55', '0676576b745294', '1', '0.00', '0', '0', '1', '1065.00', '1065', '1065', '0', '1', '2024-12-20 15:58:28', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '5' ,'0','','','','','-1','0','0','0','0','0','1065','0','','0','0','1065','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150410', '0', '2024-12-20 15:58:28', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1065', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 15:52:55','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34153;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('205','06798', '150410', '5', '15436', '1', '160', '160', '0', '', '1', '2024-12-20 15:58:28', '15436', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34153-1,','1','1','0','0','160','160','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 205.00 , meanbuyprice = 205.00, lastbuyprice_withDiscount = 205.00, meanbuyprice_withDiscount = 205.00
        
                where sellbilldetailid = 549537;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15436, '2024-12-20', 160, 205, 205
                    , 205, 205, 205, 205
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+160, sellCostBuyPrice =sellCostBuyPrice+205
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+205, sellCostMeanBuyPrice = sellCostMeanBuyPrice+205
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+205, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+205
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+205
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 160, 205, 205
                    , 205, 205, 205, 205
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+160, sellCostBuyPrice =sellCostBuyPrice+205
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+205, sellCostMeanBuyPrice = sellCostMeanBuyPrice+205
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+205, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+205
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+205
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-20 15:58:28' WHERE storedetailid = '15435';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15436', '1', '1', '1', '150410', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-20 15:58:28','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31175;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('330','06170', '150410', '5', '14024', '1', '185', '185', '0', '', '1', '2024-12-20 15:58:28', '14024', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31175-1,','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
        , lastbuyprice_withTax = 330, meanbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 330
                where sellbilldetailid = 549538;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14024, '2024-12-20', 185, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+330
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 185, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+330
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '104', storedetaildate = '2024-12-20 15:58:28' WHERE storedetailid = '14023';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14024', '1', '1', '1', '150410', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-20 15:58:28','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33477;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('330','06642', '150410', '5', '15122', '2', '265', '530', '0', '', '1', '2024-12-20 15:58:28', '15122', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33477-1,','1','1','0','0','265','530','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
        
                where sellbilldetailid = 549539;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15122, '2024-12-20', 530, 660, 660
                    , 660, 660, 660, 660
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+660
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 530, 660, 660
                    , 660, 660, 660, 660
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+660
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '104', storedetaildate = '2024-12-20 15:58:28' WHERE storedetailid = '15121';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15122', '1', '2', '1', '150410', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '-1', '104', '2024-12-20 15:58:28','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34284;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06814', '150410', '5', '15501', '1', '190', '190', '0', '', '1', '2024-12-20 15:58:28', '15501', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34284-1,','1','1','0','0','190','190','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 225.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 225.00
        
                where sellbilldetailid = 549540;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15501, '2024-12-20', 190, 225, 225
                    , 225, 225, 225, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+225
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+225
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 190, 225, 225
                    , 225, 225, 225, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+225
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+225
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '104', storedetaildate = '2024-12-20 15:58:28' WHERE storedetailid = '15500';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15501', '1', '1', '1', '150410', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-20 15:58:28','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '26000',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24935','1065', '0', '1', 'اضافة فاتورة مبيعات', '150410', '26000', '2024-12-20 15:58:28', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1065, 1420, 1420
                    , 1420, 1420, 1420, 1420
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1065, sellCostBuyPrice =sellCostBuyPrice+1420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+330
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1065, 1420, 1420
                    , 1420, 1420, 1420, 1420
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1065, sellCostBuyPrice =sellCostBuyPrice+1420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+330
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1065, 1420, 1420
                    , 1420, 1420, 1420, 1420, 330, 330)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1065, netSellCostBuyPrice = netSellCostBuyPrice+1420
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1420
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1420
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1420
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1420
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1420
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+330
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+330;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676576b745294 and sellbillId = 150410 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:28:29";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 15:58:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 15:58:29', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:30:07";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:00:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:00:07', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:30:18";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:00:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:00:18', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:30:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:00:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:00:27', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765780554797
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9362,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:58:29', '06765780554797', '9362', '15.00', '293', '15', '1', '293.00', '278', '0', '278', '1', '2024-12-20 16:00:27', '', '104', '0', 'اية سعيدk880', '1', '1', '3', '5', 'اية سعيدk880', '2' ,'0','','','','','-1','0','0','0','0','0','278','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '293', userid = '104' WHERE clientid = '9362';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9362','15.00','278','0','اضافة فاتورة مبيعات','150411', '293', '2024-12-20 16:00:27', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '278', '0', null, '0', null, null,'', '0','1','1','278','1','2024-12-20 15:58:29','0','0');
UPDATE client SET  inUse = 0 where clientid = 9362;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36358;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06603', '150411', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-20 16:00:27', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36358-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 226.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 226.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 227, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549541;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15038, '2024-12-20', 275.15358361775, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275.15358361775, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 275.15358361775, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275.15358361775, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '45', userid = '104', storedetaildate = '2024-12-20 16:00:27' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '150411', 'اضافة فاتورة مبيعات', 'sellbillController.php', '46', '45', '104', '2024-12-20 16:00:27','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150411', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-20 16:00:27', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','3','3','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 5 where clientid = 9362;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 278, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+278, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9362, '2024-12-20', 278, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+278, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 278, 225, 225
                    , 226, 225, 226, 235.95, 225, 227)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+278, netSellCostBuyPrice = netSellCostBuyPrice+225
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+225
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+226
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+225
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+226
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+235.95
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+225
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+227;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765780554797 and sellbillId = 150411 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:30:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:00:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:00:28', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:30:30";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:00:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:00:30', '2', 'editsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=149253');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:30:48";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:00:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:00:48', '2', 'update', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 149253 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 149253 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149253;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 16:00:48', userid = '75',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '149253';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 34609;
UPDATE sellbilldetail SET  lastbuyprice = 510.00 , meanbuyprice = 510.00, lastbuyprice_withDiscount = 510.00, meanbuyprice_withDiscount = 510.00
        , lastbuyprice_withTax = 510, meanbuyprice_withTax = 510, lastbuyprice_withDiscountAndTax = 510
                where sellbilldetailid = 545351;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15696, '2024-12-20', 1220, 1020, 1020
                    , 1020, 1020, 1020, 1020
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 1020, 1020, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1220, sellCostBuyPrice =sellCostBuyPrice-1020
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1020, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1020
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1020, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1020
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1020
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1020
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1020
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-2
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1220, 1020, 1020
                    , 1020, 1020, 1020, 1020
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1020, 1020, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1220, sellCostBuyPrice =sellCostBuyPrice-1020
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1020, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1020
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1020, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1020
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1020
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1020
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1020
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '4', userid = '2', storedetaildate = '2024-12-20 16:00:48' WHERE storedetailid = '15695';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15696', '1', '2', '0', '149253', 'تعديل فاتورة مبيعات', 'sellbillController.php', '2', '4', '2', '2024-12-13 11:43:38','0','0');
CALL clientInUse(1815,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '2' WHERE clientid = '1815';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1815','1253.00','1253.00','1','تعديل فاتورة مبيعات','149253', '0', '2024-12-13 11:43:38', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '1253', '0', null, '0', null, null,'', '0','1','1','1253','1','2024-12-13 11:43:38','0','0');
UPDATE client SET  inUse = 0 where clientid = 1815;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1253, 1020, 1020
                    , 1020, 1020, 1020, 1020
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1020, 1020, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1253, sellCostBuyPrice =sellCostBuyPrice-1020
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1020, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1020
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1020, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1020
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1020
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1020
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1020
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1815, '2024-12-20', 1253, 1020, 1020
                    , 1020, 1020, 1020, 1020
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1020, 1020, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1253, sellCostBuyPrice =sellCostBuyPrice-1020
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1020, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1020
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1020, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1020
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1020
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1020
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1020
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1253, 1020, 1020
                    , 1020, 1020, 1020, 1020, 1020, 1020)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-1253, netSellCostBuyPrice = netSellCostBuyPrice-1020
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-1020
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-1020
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-1020
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-1020
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-1020
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-1020
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-1020;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 149253 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 149253 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(1815,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-13 11:43:38', '0675c01cac3921', '1815', '0.00', '610', '0', '1', '610', '610', '0', '610', '1', '2024-12-13 11:43:38', '', '2', '0', 'حنان مبارك 58', '2', '1', '3', '80', 'حنان مبارك 58', '1', '149253', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-13','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '610', userid = '2' WHERE clientid = '1815';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1815','0.00','610','0','اضافة فاتورة مبيعات (معدله)','150412', '610', '2024-12-20 16:00:48', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '610', '0', null, '0', null, null,'', '0','1','1','1253','1','2024-12-13 11:43:38','0','0');
UPDATE client SET  inUse = 0 where clientid = 1815;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34609;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('510','H1410', '150412', '14', '15696', '1', '610', '610', '0', '', '1', '2024-12-20 16:00:48', '15696', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34609-1,','1','1','0','0','610','610','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 510.00 , meanbuyprice = 510.00, lastbuyprice_withDiscount = 510.00, meanbuyprice_withDiscount = 510.00
        , lastbuyprice_withTax = 510, meanbuyprice_withTax = 510, lastbuyprice_withDiscountAndTax = 510
                where sellbilldetailid = 549543;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15696, '2024-12-20', 610, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+510
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+510
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+510
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+510
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+510
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0, 510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+510
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+510
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+510
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+510
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+510
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '2', storedetaildate = '2024-12-20 16:00:48' WHERE storedetailid = '15695';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15696', '1', '1', '1', '150412', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '4', '3', '2', '2024-12-20 16:00:48','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 610, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+510
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+510
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+510
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+510
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+510
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1815, '2024-12-20', 610, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+510
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+510
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+510
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+510
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+510
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 610, 510, 510
                    , 510, 510, 510, 510, 510, 510)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+610, netSellCostBuyPrice = netSellCostBuyPrice+510
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+510
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+510
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+510
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+510
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+510
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+510
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+510;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 149253 and newid=150412 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:30:49";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:00:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:00:49', '2', 'editprint', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150412');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:31:41";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:01:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:01:41', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:31:49";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:01:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 16:01:50', '77', '', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:31:51";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:32:01";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:02:01", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:02:01', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:33:07";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:03:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:03:07', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:33:11";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:03:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:03:11', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:33:11";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:03:11", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:03:11', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765536d5aed7
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7370,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 13:22:21', '06765536d5aed7', '7370', '0.00', '1364', '0', '1', '1364.00', '1364', '0', '1364', '1', '2024-12-20 16:03:12', '', '75', '0', 'شيماء جبريل W76', '2', '1', '3', '83', 'شيماء جبريل W76', '6' ,'0','','','','','-1','0','0','0','0','0','1364','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1364', userid = '75' WHERE clientid = '7370';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7370','0.00','1364','0','اضافة فاتورة مبيعات','150413', '1364', '2024-12-20 16:03:12', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1364', '0', null, '0', null, null,'', '0','1','1','1364','1','2024-12-20 13:22:21','0','0');
UPDATE client SET  inUse = 0 where clientid = 7370;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36168;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('315','R3334', '150413', '1', '16400', '1', '370', '370', '0', '', '1', '2024-12-20 16:03:12', '16400', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36168-1,','1','1','0','0','370','370','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 315.00 , meanbuyprice = 315.00, lastbuyprice_withDiscount = 315.00, meanbuyprice_withDiscount = 315.00
        , lastbuyprice_withTax = 315, meanbuyprice_withTax = 315, lastbuyprice_withDiscountAndTax = 315
                where sellbilldetailid = 549544;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16400, '2024-12-20', 370, 315, 315
                    , 315, 315, 315, 315
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 315, 315, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+315
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+315, sellCostMeanBuyPrice = sellCostMeanBuyPrice+315
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+315, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+315
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+315
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+315
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+315
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 370, 315, 315
                    , 315, 315, 315, 315
                    , 0, 0, 0, 0
                    , 0, 0, 0, 315, 315, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+315
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+315, sellCostMeanBuyPrice = sellCostMeanBuyPrice+315
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+315, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+315
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+315
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+315
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+315
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '75', storedetaildate = '2024-12-20 16:03:12' WHERE storedetailid = '16399';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16400', '1', '1', '1', '150413', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-20 16:03:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35399;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','07047', '150413', '5', '16043', '1', '410', '410', '0', '', '1', '2024-12-20 16:03:12', '16043', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35399-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 279.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 279.00
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 297, lastbuyprice_withDiscountAndTax = 350
                where sellbilldetailid = 549545;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16043, '2024-12-20', 410, 350, 350
                    , 279, 350, 279, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 350, 297, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+279
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+279
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+297
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 410, 350, 350
                    , 279, 350, 279, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 297, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+279
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+279
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+297
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '75', storedetaildate = '2024-12-20 16:03:12' WHERE storedetailid = '16042';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16043', '1', '1', '1', '150413', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-20 16:03:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35371;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('280','H1526', '150413', '14', '16028', '1', '350', '350', '0', '', '1', '2024-12-20 16:03:12', '16028', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35371-1,','1','1','0','0','350','350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 280, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 549546;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16028, '2024-12-20', 350, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 350, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 16:03:12' WHERE storedetailid = '16027';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16028', '1', '1', '1', '150413', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 16:03:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36375;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07298', '150413', '5', '16442', '1', '200', '200', '0', '', '1', '2024-12-20 16:03:12', '16442', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36375-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549547;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16442, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '75', storedetaildate = '2024-12-20 16:03:12' WHERE storedetailid = '16441';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16442', '1', '1', '1', '150413', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-20 16:03:12','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150413', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 16:03:12', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150413', '17', '10291', '1', '14', '14', '0', '', '1', '2024-12-20 16:03:12', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','14','14','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 83 where clientid = 7370;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1364, 1085, 1085
                    , 1014, 1085, 1014, 1085
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1085, 1032, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1364, sellCostBuyPrice =sellCostBuyPrice+1085
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1085, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1014
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1085, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1014
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1085
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1085
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1032
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7370, '2024-12-20', 1364, 1085, 1085
                    , 1014, 1085, 1014, 1085
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1085, 1032, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1364, sellCostBuyPrice =sellCostBuyPrice+1085
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1085, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1014
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1085, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1014
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1085
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1085
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1032
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1364, 1085, 1085
                    , 1014, 1085, 1014, 1085, 1085, 1032)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1364, netSellCostBuyPrice = netSellCostBuyPrice+1085
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1085
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1014
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1085
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1014
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1085
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1085
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1032;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765536d5aed7 and sellbillId = 150413 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:33:13";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:03:13", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:03:13', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('R3348','','1','115','185', '185','185', '2024-12-20', '0', '77', '1', 'R3348', '0', '0', '0', '0', '0', '115','115','115','115','115','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','115','115','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16523, 1,'2024-12-20 16:03:15',77)
                ON DUPLICATE KEY UPDATE productid = 16523, edited = 1, sysdate = '2024-12-20 16:03:15', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16523', '1', '2024-12-20', '77', '0','1652301','185','185','185','115','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16523', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16523', '1', '0', '0', '16523', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('R3346','','1','110','170', '170','170', '2024-12-20', '0', '77', '1', 'R3346', '0', '0', '0', '0', '0', '110','110','110','110','110','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','110','110','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16524, 1,'2024-12-20 16:04:02',77)
                ON DUPLICATE KEY UPDATE productid = 16524, edited = 1, sysdate = '2024-12-20 16:04:02', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16524', '1', '2024-12-20', '77', '0','1652401','170','170','170','110','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16524', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16524', '1', '0', '0', '16524', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE productunit SET unitid = '1', productid = '16523', productnumber = '1.00', productunitdate = '2024-12-20', userid = '77', conditions = '0',proUnitParcode='1652301',proUnitSellAllPrice='185',proUnitSellHalfPrice='185',proUnitSellUnitPrice ='185',proUnitBuyPrice='115',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16523';
UPDATE product SET productName = 'R3348', productDescription = '', productCatId = '1', productBuyPrice = '135', productSellAllPrice = '185', productSellUnitPrice = '185', productSellHalfPrice = '185', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3348',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '115.00',lastbuyprice_withDiscount = '115',meanbuyprice = '125',meanbuyprice_withDiscount = '125' , productbuypricereal = '115' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='115',meanbuyprice_withTax='115',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='0'  WHERE productId = '16523';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:34:28";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:04:28", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:04:28', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('0676578da0c4ac', '2024-12-20 16:02:02', '235', '37855.00', '40855', '0', '0', '3000',  '3000', '0', '3000', '1', '2024-12-20 16:04:28', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('R3348', '14172', '1', '16523', '10', '135', '1350', '0', '', '2024-12-20 16:04:28', '16523','','','0','0','0','0','0',null,'135','1350','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:02:02', 1, 16523, 0, 0
                    , 135, 10, 0, 0, 77, '2024-12-20 16:04:28')
                ON DUPLICATE KEY UPDATE buyprice = 135,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:04:28' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16523', '135', '10', '0', 'buyBillController.php', '32793', '', '0', '0');
UPDATE product SET  productBuyPrice = "135" WHERE productId = 16523 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32793 ;
UPDATE product SET productName = 'R3348', productDescription = '', productCatId = '1', productBuyPrice = '135.00', productSellAllPrice = '185.00', productSellUnitPrice = '185.00', productSellHalfPrice = '185.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3348',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '135',lastbuyprice_withDiscount = '135',meanbuyprice = '135',meanbuyprice_withDiscount = '135' , productbuypricereal = '115.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='135',meanbuyprice_withTax='135',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='135'  WHERE productId = '16523';
UPDATE buybilldetail SET  lastbuyprice = 135 , meanbuyprice = 135, lastbuyprice_withDiscount = 135, meanbuyprice_withDiscount = 135
        , lastbuyprice_withTax = 135, meanbuyprice_withTax = 135, lastbuyprice_withDiscountAndTax = 135
                where buybilldetailid = 32793;
UPDATE productunit SET proUnitBuyPrice  = 135 * productnumber WHERE productid = 16523;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16522';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16523', '1', '10', '0', '14172', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-20 16:02:02','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('R3346', '14172', '1', '16524', '15', '110', '1650', '0', '', '2024-12-20 16:04:28', '16524','','','0','0','0','0','0',null,'110','1650','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:02:02', 1, 16524, 0, 0
                    , 110, 15, 0, 0, 77, '2024-12-20 16:04:28')
                ON DUPLICATE KEY UPDATE buyprice = 110,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:04:28' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16524', '110', '15', '0', 'buyBillController.php', '32794', '', '0', '0');
UPDATE product SET  productBuyPrice = "110" WHERE productId = 16524 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32794 ;
UPDATE product SET productName = 'R3346', productDescription = '', productCatId = '1', productBuyPrice = '110.00', productSellAllPrice = '170.00', productSellUnitPrice = '170.00', productSellHalfPrice = '170.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3346',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '110',lastbuyprice_withDiscount = '110',meanbuyprice = '110',meanbuyprice_withDiscount = '110' , productbuypricereal = '110.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='110',meanbuyprice_withTax='110',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='110'  WHERE productId = '16524';
UPDATE buybilldetail SET  lastbuyprice = 110 , meanbuyprice = 110, lastbuyprice_withDiscount = 110, meanbuyprice_withDiscount = 110
        , lastbuyprice_withTax = 110, meanbuyprice_withTax = 110, lastbuyprice_withDiscountAndTax = 110
                where buybilldetailid = 32794;
UPDATE productunit SET proUnitBuyPrice  = 110 * productnumber WHERE productid = 16524;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16523';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16524', '1', '15', '0', '14172', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 16:02:02','0','0');
UPDATE supplier SET  suppliercurrentDebt = '40855',suppliercurrentDebtInCurrency= '40855' , userid = '77', supplierdate = '2024-12-20 16:04:28'   WHERE supplierid = '235';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('235', '37855.00', '3000', '0', 'اضافة فاتورة مشتريات', '14172', '40855', '2024-12-20 16:02:02', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','3000','1','37855','3000','40855','0');
update buybill set dailyentryid='0,' where buybillid=14172;
COMMIT;
UPDATE product SET overAllAveragePrice = 135 WHERE productId = 16523;UPDATE product SET overAllAveragePrice = 110 WHERE productId = 16524;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:34:29";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:04:29", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:04:29', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14172');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:34:53";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:04:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:04:53', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765791fc57d1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1815,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:03:11', '06765791fc57d1', '1815', '610.00', '1360', '0', '1', '750.00', '750', '0', '750', '1', '2024-12-20 16:04:53', '', '104', '0', 'حنان مبارك 58', '1', '1', '3', '6', 'حنان مبارك 58', '2' ,'0','','','','','-1','0','0','0','0','0','750','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1360', userid = '104' WHERE clientid = '1815';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1815','610.00','750','0','اضافة فاتورة مبيعات','150414', '1360', '2024-12-20 16:04:53', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '750', '0', null, '0', null, null,'', '0','1','1','750','1','2024-12-20 16:03:11','0','0');
UPDATE client SET  inUse = 0 where clientid = 1815;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36469;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('335','07221', '150414', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-20 16:04:53', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36469-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 549550;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16279, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '58', userid = '104', storedetaildate = '2024-12-20 16:04:53' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150414', 'اضافة فاتورة مبيعات', 'sellbillController.php', '59', '58', '104', '2024-12-20 16:04:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35730;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('285','R3303', '150414', '1', '16077', '1', '350', '350', '0', '', '1', '2024-12-20 16:04:53', '16077', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35730-1,','1','1','0','0','350','350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 285.00 , meanbuyprice = 285.00, lastbuyprice_withDiscount = 285.00, meanbuyprice_withDiscount = 285.00
        , lastbuyprice_withTax = 285, meanbuyprice_withTax = 285, lastbuyprice_withDiscountAndTax = 285
                where sellbilldetailid = 549551;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16077, '2024-12-20', 350, 285, 285
                    , 285, 285, 285, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 285, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+285
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+285
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+285
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+285
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 350, 285, 285
                    , 285, 285, 285, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0, 285, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+285
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+285
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+285
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+285
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '104', storedetaildate = '2024-12-20 16:04:53' WHERE storedetailid = '16076';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16077', '1', '1', '1', '150414', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-20 16:04:53','0','0');
UPDATE client SET  delegateid = 6 where clientid = 1815;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 750, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,620, 608, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+620, sellCostMeanBuyPrice = sellCostMeanBuyPrice+620
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+620
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+620
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+608
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1815, '2024-12-20', 750, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,620, 608, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+620, sellCostMeanBuyPrice = sellCostMeanBuyPrice+620
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+620
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+620
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+608
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 750, 620, 620
                    , 620, 620, 620, 620, 620, 608)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+750, netSellCostBuyPrice = netSellCostBuyPrice+620
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+620
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+620
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+620
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+620
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+620
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+620
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+608;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765791fc57d1 and sellbillId = 150414 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:34:54";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:04:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:04:54', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:36:26";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:06:26", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:06:26', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765792137ecf
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10268,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:03:13', '06765792137ecf', '10268', '-209.00', '-42', '0', '1', '167.00', '167', '0', '167', '1', '2024-12-20 16:06:26', '', '75', '0', 'اسماء رمضان 33', '2', '1', '3', '89', 'اسماء رمضان 33', '2' ,'0','','','','','-1','0','0','0','0','0','167','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '-42', userid = '75' WHERE clientid = '10268';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10268','-209.00','167','0','اضافة فاتورة مبيعات','150415', '-42', '2024-12-20 16:06:26', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '167', '0', null, '0', null, null,'', '0','1','1','167','1','2024-12-20 16:03:13','0','0');
UPDATE client SET  inUse = 0 where clientid = 10268;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35857;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('115','R3322', '150415', '1', '16265', '1', '165', '165', '0', '', '1', '2024-12-20 16:06:26', '16265', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35857-1,','1','1','0','0','165','165','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 115.00 , meanbuyprice = 115.00, lastbuyprice_withDiscount = 115.00, meanbuyprice_withDiscount = 115.00
        , lastbuyprice_withTax = 115, meanbuyprice_withTax = 115, lastbuyprice_withDiscountAndTax = 115
                where sellbilldetailid = 549552;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16265, '2024-12-20', 165, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 115, 115, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+115
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+115
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+115
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 165, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0, 115, 115, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+115
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+115
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+115
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '17', userid = '75', storedetaildate = '2024-12-20 16:06:26' WHERE storedetailid = '16264';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16265', '1', '1', '1', '150415', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '75', '2024-12-20 16:06:26','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150415', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-20 16:06:26', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','2','2','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 89 where clientid = 10268;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 167, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,115, 115, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+167, sellCostBuyPrice =sellCostBuyPrice+115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+115
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+115
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+115
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10268, '2024-12-20', 167, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,115, 115, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+167, sellCostBuyPrice =sellCostBuyPrice+115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+115
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+115
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+115
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 167, 115, 115
                    , 115, 115, 115, 115, 115, 115)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+167, netSellCostBuyPrice = netSellCostBuyPrice+115
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+115
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+115
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+115
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+115
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+115
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+115
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+115;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765792137ecf and sellbillId = 150415 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:36:27";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:06:27", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:06:27', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:37:45";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:07:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:07:45', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676579865a78b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:04:54', '0676579865a78b', '1', '0.00', '0', '0', '1', '1420.00', '1420', '1420', '0', '1', '2024-12-20 16:07:45', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1420','0','','0','0','1420','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150416', '0', '2024-12-20 16:07:45', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1420', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:04:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36094;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('730','07143', '150416', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-20 16:07:45', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36094-1,','1','1','0','0','810','810','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 730.00 , meanbuyprice = 730.00, lastbuyprice_withDiscount = 730.00, meanbuyprice_withDiscount = 730.00
        , lastbuyprice_withTax = 730, meanbuyprice_withTax = 730, lastbuyprice_withDiscountAndTax = 730
                where sellbilldetailid = 549554;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16205, '2024-12-20', 810, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+730
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+730, sellCostMeanBuyPrice = sellCostMeanBuyPrice+730
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+730, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+730
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+730
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+730
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+730
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 810, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0, 730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+730
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+730, sellCostMeanBuyPrice = sellCostMeanBuyPrice+730
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+730, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+730
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+730
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+730
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+730
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '58', userid = '104', storedetaildate = '2024-12-20 16:07:45' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '150416', 'اضافة فاتورة مبيعات', 'sellbillController.php', '59', '58', '104', '2024-12-20 16:07:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35151;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('385','R3292', '150416', '1', '15921', '1', '450', '450', '0', '', '1', '2024-12-20 16:07:45', '15921', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35151-1,','1','1','0','0','450','450','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 385.00 , meanbuyprice = 385.00, lastbuyprice_withDiscount = 385.00, meanbuyprice_withDiscount = 385.00
        , lastbuyprice_withTax = 385, meanbuyprice_withTax = 385, lastbuyprice_withDiscountAndTax = 385
                where sellbilldetailid = 549555;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15921, '2024-12-20', 450, 385, 385
                    , 385, 385, 385, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 385, 385, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+385
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 450, 385, 385
                    , 385, 385, 385, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 385, 385, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+385
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '104', storedetaildate = '2024-12-20 16:07:45' WHERE storedetailid = '15920';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15921', '1', '1', '1', '150416', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-20 16:07:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36381;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('110','R3342', '150416', '1', '16446', '1', '160', '160', '0', '', '1', '2024-12-20 16:07:45', '16446', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36381-1,','1','1','0','0','160','160','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 110.00 , meanbuyprice = 110.00, lastbuyprice_withDiscount = 110.00, meanbuyprice_withDiscount = 110.00
        , lastbuyprice_withTax = 110, meanbuyprice_withTax = 110, lastbuyprice_withDiscountAndTax = 110
                where sellbilldetailid = 549556;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16446, '2024-12-20', 160, 110, 110
                    , 110, 110, 110, 110
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 110, 110, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+160, sellCostBuyPrice =sellCostBuyPrice+110
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+110, sellCostMeanBuyPrice = sellCostMeanBuyPrice+110
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+110, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+110
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+110
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+110
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+110
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 160, 110, 110
                    , 110, 110, 110, 110
                    , 0, 0, 0, 0
                    , 0, 0, 0, 110, 110, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+160, sellCostBuyPrice =sellCostBuyPrice+110
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+110, sellCostMeanBuyPrice = sellCostMeanBuyPrice+110
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+110, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+110
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+110
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+110
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+110
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '22', userid = '104', storedetaildate = '2024-12-20 16:07:45' WHERE storedetailid = '16445';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16446', '1', '1', '1', '150416', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '104', '2024-12-20 16:07:45','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '27420',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26000','1420', '0', '1', 'اضافة فاتورة مبيعات', '150416', '27420', '2024-12-20 16:07:45', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 97 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1420, 1225, 1225
                    , 1225, 1225, 1225, 1225
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1225, 1225, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1420, sellCostBuyPrice =sellCostBuyPrice+1225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1225
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1225
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1225
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1420, 1225, 1225
                    , 1225, 1225, 1225, 1225
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1225, 1225, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1420, sellCostBuyPrice =sellCostBuyPrice+1225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1225
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1225
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1225
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1420, 1225, 1225
                    , 1225, 1225, 1225, 1225, 1225, 1225)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1420, netSellCostBuyPrice = netSellCostBuyPrice+1225
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1225
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1225
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1225
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1225
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1225
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1225
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1225;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676579865a78b and sellbillId = 150416 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:37:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:07:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:07:46', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:38:44";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:08:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:08:44', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:39:01";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:09:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:09:01', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657a6cbfcf3
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 16:08:44', '067657a6cbfcf3', '1', '0.00', '0', '0', '1', '280', '280', '-280', '0', '1', '2024-12-20 16:09:01', '', '104', '0', 'نقدي','1', '0', '5', '5', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-280','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16851', '0', '2024-12-20 16:09:01', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '280', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:08:44','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('215.00', 'H1470', '16851', '14', '15887', '1', '280', '280', '0', '', '1', '0', '15887', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','280','280','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 215.00 , meanbuyprice = 169.00, lastbuyprice_withDiscount = 215.00, meanbuyprice_withDiscount = 169.00
        , lastbuyprice_withTax = 215, meanbuyprice_withTax = 123, lastbuyprice_withDiscountAndTax = 215
                where returnsellbilldetailid = 22041;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15887, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 280, 215, 215, 169
                    , 215, 169, 215, 0, 1, 0, 0, 215, 123)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+280, returnSellCostBuyPrice = returnSellCostBuyPrice+215, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+215
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+169, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+215
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+169
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+215
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+215
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+123
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 280, 215, 215, 169
                    , 215, 169, 215, 0, 0, 215, 123)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+280, returnSellCostBuyPrice = returnSellCostBuyPrice+215, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+215
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+169, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+215
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+169
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+215
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+215
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+123;
UPDATE storedetail SET  productquantity = '7', userid = '104', storedetaildate = '2024-12-20 16:09:01' WHERE storedetailid = '15886';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15887', '1', '1', '0', '16851', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '6', '7', '104', '2024-12-20 16:09:01','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '27140',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('27420','-280', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16851', '27140', '2024-12-20 16:09:01', '104',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 280, 215, 215, 169
                    , 215, 169, 215 ,0, 0, 215, 123)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+280, returnSellCostBuyPrice = returnSellCostBuyPrice+215, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+215
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+169, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+215
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+169
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+215
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+215
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+123;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 280, 215, 215, 169
                    , 215, 169, 215 ,0, 0, 215, 123)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+280, returnSellCostBuyPrice = returnSellCostBuyPrice+215, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+215
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+169, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+215
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+169
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+215
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+215
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+123;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -280, -215, -215
                    , -169, -215, -169, -215, -215, -123)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-280, netSellCostBuyPrice = netSellCostBuyPrice+-215
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-215
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-169
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-215
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-169
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-215
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-215
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-123;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657a6cbfcf3 and sellbillId = 16851 and returnsellbillId = 16851
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:39:02";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:09:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:09:02', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:40:01";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:10:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:10:01', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:40:40";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:10:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 16:10:40', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:40:45";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:10:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 16:10:45', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'مشال', '', '20', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '27120',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('27140.00','20', '1', '1', 'إضافة مصروف', '25910', '27120', '2024-12-20 16:10:46', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'مشال', expensesdetails = '', expensesValue = '20.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25910';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:40:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:10:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 16:10:46', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:40:48";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:10:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:10:48', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:40:55";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:10:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:10:55', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:41:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:11:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:11:38', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:42:16";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:12:16", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:12:16', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765770383691
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10771,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:54:11', '06765770383691', '10771', '0.00', '1232', '0', '1', '1232.00', '1232', '0', '1232', '1', '2024-12-20 16:12:16', '', '75', '0', 'عروب الزقازيق 52', '2', '1', '3', '98', 'عروب الزقازيق 52', '6' ,'0','','','','','-1','0','0','0','0','0','1232','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1232', userid = '75' WHERE clientid = '10771';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10771','0.00','1232','0','اضافة فاتورة مبيعات','150417', '1232', '2024-12-20 16:12:16', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1232', '0', null, '0', null, null,'', '0','1','1','1232','1','2024-12-20 15:54:11','0','0');
UPDATE client SET  inUse = 0 where clientid = 10771;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35893;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('270','R3325', '150417', '1', '16290', '2', '290', '580', '0', '', '1', '2024-12-20 16:12:16', '16290', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35893-2,','1','1','0','0','290','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 252.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 252.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 254, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 549557;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16290, '2024-12-20', 580, 500, 500
                    , 504, 500, 504, 513.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 500, 508, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+504
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+504
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+513.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+508
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 580, 500, 500
                    , 504, 500, 504, 513.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 508, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+504
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+504
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+513.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+508
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '35', userid = '75', storedetaildate = '2024-12-20 16:12:16' WHERE storedetailid = '16289';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16290', '1', '2', '1', '150417', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37', '35', '75', '2024-12-20 16:12:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36368;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('150','07296', '150417', '5', '16435', '1', '200', '200', '0', '', '1', '2024-12-20 16:12:16', '16435', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36368-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        , lastbuyprice_withTax = 150, meanbuyprice_withTax = 150, lastbuyprice_withDiscountAndTax = 150
                where sellbilldetailid = 549558;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16435, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '75', storedetaildate = '2024-12-20 16:12:16' WHERE storedetailid = '16434';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16435', '1', '1', '1', '150417', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-20 16:12:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34820;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('360','R3275', '150417', '1', '15818', '1', '420', '420', '0', '', '1', '2024-12-20 16:12:16', '15818', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34820-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549559;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15818, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '75', storedetaildate = '2024-12-20 16:12:16' WHERE storedetailid = '15817';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15818', '1', '1', '1', '150417', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-20 16:12:16','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150417', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 16:12:16', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150417', '17', '10291', '1', '12', '12', '0', '', '1', '2024-12-20 16:12:16', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','12','12','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 98 where clientid = 10771;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1232, 1010, 1010
                    , 1014, 1010, 1014, 1023.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1010, 1018, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1232, sellCostBuyPrice =sellCostBuyPrice+1010
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1010, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1014
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1010, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1014
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1023.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1010
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1018
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10771, '2024-12-20', 1232, 1010, 1010
                    , 1014, 1010, 1014, 1023.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1010, 1018, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1232, sellCostBuyPrice =sellCostBuyPrice+1010
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1010, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1014
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1010, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1014
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1023.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1010
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1018
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1232, 1010, 1010
                    , 1014, 1010, 1014, 1023.34, 1010, 1018)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1232, netSellCostBuyPrice = netSellCostBuyPrice+1010
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1010
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1014
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1010
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1014
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1023.34
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1010
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1018;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765770383691 and sellbillId = 150417 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:42:17";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:12:17", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:12:17', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('زينة محمد 12' , '', '', '01069012103', '0', '', '0', '2024-12-20 16:12:31', '104', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10772', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10772','0','0','0','إضافة عميل جديد','10772', '0', '2024-12-20 16:12:31', '104', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('زينة محمد 12', 'زينة محمد 12', 'زينة محمد 12', 'زينة محمد 12', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '104', '0', '2024-12-20 16:12:31');
UPDATE client SET clientname = 'زينة محمد 12', clientaddress = '', clientphone = '', clientmobile = '01069012103', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '104'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12614',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10772';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:43:39";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:13:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:13:39', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657ae87a656
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10772,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:10:48', '067657ae87a656', '10772', '0.00', '1384', '0', '1', '1384.00', '1384', '0', '1384', '1', '2024-12-20 16:13:39', '', '104', '0', 'زينة محمد 12', '1', '1', '3', '95', 'زينة محمد 12', '4' ,'0','','','','','-1','0','0','0','0','0','1384','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1384', userid = '104' WHERE clientid = '10772';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10772','0.00','1384','0','اضافة فاتورة مبيعات','150418', '1384', '2024-12-20 16:13:39', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1384', '0', null, '0', null, null,'', '0','1','1','1384','1','2024-12-20 16:10:48','0','0');
UPDATE client SET  inUse = 0 where clientid = 10772;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35196;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('380','H1491', '150418', '14', '15911', '1', '460', '460', '0', '', '1', '2024-12-20 16:13:39', '15911', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35196-1,','1','1','0','0','460','460','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 380.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 380.00
        , lastbuyprice_withTax = 380, meanbuyprice_withTax = 380, lastbuyprice_withDiscountAndTax = 380
                where sellbilldetailid = 549562;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15911, '2024-12-20', 460, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 380, 380, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+380
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 460, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 380, 380, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+380
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-20 16:13:39' WHERE storedetailid = '15910';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15911', '1', '1', '1', '150418', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-20 16:13:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36115;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('280','07195', '150418', '5', '16275', '1', '330', '330', '0', '', '1', '2024-12-20 16:13:39', '16275', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36115-1,','1','1','0','0','330','330','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 281.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 281.00
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 281, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 549563;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16275, '2024-12-20', 330, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 281, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+281
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+281
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+281
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 330, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 281, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+281
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+281
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+281
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '40', userid = '104', storedetaildate = '2024-12-20 16:13:39' WHERE storedetailid = '16274';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16275', '1', '1', '1', '150418', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41', '40', '104', '2024-12-20 16:13:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35977;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('510','07197', '150418', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-20 16:13:39', '16297', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35977-1,','1','1','0','0','580','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 503.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 503.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 507, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 549564;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16297, '2024-12-20', 580, 500, 500
                    , 503, 500, 503, 507.69
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 507, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+507.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+507
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 580, 500, 500
                    , 503, 500, 503, 507.69
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 507, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+507.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+507
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '132', userid = '104', storedetaildate = '2024-12-20 16:13:39' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '150418', 'اضافة فاتورة مبيعات', 'sellbillController.php', '133', '132', '104', '2024-12-20 16:13:39','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150418', '17', '10291', '1', '14', '14', '0', '', '1', '2024-12-20 16:13:39', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','14','14','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 95 where clientid = 10772;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1384, 1160, 1160
                    , 1164, 1160, 1164, 1167.69
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1160, 1168, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1384, sellCostBuyPrice =sellCostBuyPrice+1160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1164
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1164
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1167.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1168
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10772, '2024-12-20', 1384, 1160, 1160
                    , 1164, 1160, 1164, 1167.69
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1160, 1168, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1384, sellCostBuyPrice =sellCostBuyPrice+1160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1164
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1164
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1167.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1168
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1384, 1160, 1160
                    , 1164, 1160, 1164, 1167.69, 1160, 1168)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1384, netSellCostBuyPrice = netSellCostBuyPrice+1160
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1160
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1164
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1160
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1164
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1167.69
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1160
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1168;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657ae87a656 and sellbillId = 150418 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:43:39";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:13:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:13:39', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:46:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:16:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:16:28', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:47:04";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:17:04", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:17:04', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657c3c663c4
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 16:16:28', '067657c3c663c4', '1', '0.00', '0', '0', '1', '210', '210', '-210', '0', '1', '2024-12-20 16:17:05', '', '104', '0', 'نقدي','1', '0', '5', '4', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-210','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16852', '0', '2024-12-20 16:17:05', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '210', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:16:28','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('130.00', '06867', '16852', '5', '15642', '1', '210', '210', '0', '', '1', '0', '15642', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','210','210','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 130.00 , meanbuyprice = 130.00, lastbuyprice_withDiscount = 130.00, meanbuyprice_withDiscount = 130.00
        , lastbuyprice_withTax = 130, meanbuyprice_withTax = 130, lastbuyprice_withDiscountAndTax = 130
                where returnsellbilldetailid = 22042;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15642, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 130, 130, 130
                    , 130, 130, 130, 0, 1, 0, 0, 130, 130)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+210, returnSellCostBuyPrice = returnSellCostBuyPrice+130, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+130
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+130, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+130
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+130
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+130
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+130
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+130
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 130, 130, 130
                    , 130, 130, 130, 0, 0, 130, 130)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+210, returnSellCostBuyPrice = returnSellCostBuyPrice+130, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+130
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+130, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+130
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+130
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+130
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+130
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+130;
UPDATE storedetail SET  productquantity = '7', userid = '104', storedetaildate = '2024-12-20 16:17:05' WHERE storedetailid = '15641';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15642', '1', '1', '0', '16852', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '6', '7', '104', '2024-12-20 16:17:05','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '26910',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('27120','-210', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16852', '26910', '2024-12-20 16:17:05', '104',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 130, 130, 130
                    , 130, 130, 130 ,0, 0, 130, 130)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+210, returnSellCostBuyPrice = returnSellCostBuyPrice+130, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+130
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+130, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+130
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+130
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+130
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+130
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+130;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 130, 130, 130
                    , 130, 130, 130 ,0, 0, 130, 130)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+210, returnSellCostBuyPrice = returnSellCostBuyPrice+130, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+130
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+130, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+130
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+130
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+130
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+130
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+130;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -210, -130, -130
                    , -130, -130, -130, -130, -130, -130)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-210, netSellCostBuyPrice = netSellCostBuyPrice+-130
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-130
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-130
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-130
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-130
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-130
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-130
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-130;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657c3c663c4 and sellbillId = 16852 and returnsellbillId = 16852
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:47:05";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:17:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:17:05', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:47:08";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:17:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:17:08', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247949
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9362,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 16:17:08', userid = '2' WHERE clientid = '9362';
UPDATE client SET  inUse = 0 where clientid = 9362;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9362','293.00','293','1','ايصال تحصيل (( قبض من عميل ))','247949', '0', '2024-12-20 15:53:52', '2', 'clientPayedDeptController.php', '   ', '293', '0', null, '0', null, null,'', '-1','1','1','293','1','','3643','0');
UPDATE save SET  savecurrentvalue = '129558.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('129265.50','293', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247964', '129558.5', '2024-12-20 16:17:08', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('اية سعيدk880', 'اية سعيدk880', 'اية سعيدk880', 'اية سعيدk880', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 16:17:09');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '293', '293', '2024-12-20', '2', '0', '0', '2024-12-20 16:17:09','اضافة ايصال سداد للعميل اية سعيدk880','1','0','0','0','247964','clientPayedDeptController.php?do=show&id=247964');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122305', '-1', '293', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '293', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122305', '12615', '293', '','0');
UPDATE accountstree SET name = 'اية سعيدk880', customName = 'اية سعيدk880', customNameEn = 'اية سعيدk880', nameEn = 'اية سعيدk880', parent = '58', accountNature = '0', theValue = '-293', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 16:17:09' WHERE id = '12615';
UPDATE clientdebtchange SET clientid = '9362', clientdebtchangebefore = '293.000', clientdebtchangeamount = '293.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247949', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 15:53:52', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '293.00',discount='', reciptid='0', dailyentryid = '122305',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='293',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247964';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247949 -clientdebtchangeId = 247964
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:47:09";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:17:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:17:09', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:47:32";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:17:32", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:17:32', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247965
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10772,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 16:17:32', userid = '2' WHERE clientid = '10772';
UPDATE client SET  inUse = 0 where clientid = 10772;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10772','1384.00','1384','1','ايصال تحصيل (( قبض من عميل ))','247965', '0', '2024-12-20 16:17:09', '2', 'clientPayedDeptController.php', '   ', '1384', '0', null, '0', null, null,'', '-1','1','1','1384','1','','3644','0');
UPDATE save SET  savecurrentvalue = '130942.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('129558.50','1384', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247965', '130942.5', '2024-12-20 16:17:32', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1384', '1384', '2024-12-20', '2', '0', '0', '2024-12-20 16:17:32','اضافة ايصال سداد للعميل زينة محمد 12','1','0','0','0','247965','clientPayedDeptController.php?do=show&id=247965');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122306', '-1', '1384', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1384', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122306', '12614', '1384', '','0');
UPDATE accountstree SET name = 'زينة محمد 12', customName = 'زينة محمد 12', customNameEn = 'زينة محمد 12', nameEn = 'زينة محمد 12', parent = '58', accountNature = '0', theValue = '-1384', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '104', del = '0', sysdate = '2024-12-20 16:12:31' WHERE id = '12614';
UPDATE clientdebtchange SET clientid = '10772', clientdebtchangebefore = '1384.000', clientdebtchangeamount = '1384.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247965', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 16:17:09', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1384.00',discount='', reciptid='0', dailyentryid = '122306',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1384',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247965';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247965 -clientdebtchangeId = 247965
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:47:33";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:17:33", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:17:33', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:47:35";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:17:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:17:35', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657b94211b3
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:13:40', '067657b94211b3', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2024-12-20 16:17:35', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150419', '0', '2024-12-20 16:17:35', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:13:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36295;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07051', '150419', '5', '16247', '1', '200', '200', '0', '', '1', '2024-12-20 16:17:35', '16247', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36295-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 58.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 58.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 25, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549566;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16247, '2024-12-20', 200, 140, 140
                    , 58, 140, 58, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 25, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+58
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+58
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+25
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 58, 140, 58, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 25, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+58
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+58
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+25
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '104', storedetaildate = '2024-12-20 16:17:35' WHERE storedetailid = '16246';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16247', '1', '1', '1', '150419', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-20 16:17:35','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '27110',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26910','200', '0', '1', 'اضافة فاتورة مبيعات', '150419', '27110', '2024-12-20 16:17:35', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 200, 140, 140
                    , 58, 140, 58, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 25, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+58
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+58
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+25
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 58, 140, 58, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 25, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+58
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+58
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+25
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 200, 140, 140
                    , 58, 140, 58, 140, 140, 25)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+140
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+140
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+58
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+140
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+58
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+140
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+25;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657b94211b3 and sellbillId = 150419 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:47:35";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:17:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:17:35', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:48:14";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:18:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:18:14', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:48:53";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:18:53", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:18:53', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676579e3a3e4c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(430,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:06:27', '0676579e3a3e4c', '430', '0.00', '3394', '0', '1', '3394.00', '3394', '0', '3394', '1', '2024-12-20 16:18:53', '', '75', '0', 'افينيس المنيا F67', '2', '1', '3', '86', 'افينيس المنيا F67', '26' ,'0','','','','','-1','0','0','0','0','0','3394','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '3394', userid = '75' WHERE clientid = '430';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('430','0.00','3394','0','اضافة فاتورة مبيعات','150420', '3394', '2024-12-20 16:18:53', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3394', '0', null, '0', null, null,'', '0','1','1','3394','1','2024-12-20 16:06:27','0','0');
UPDATE client SET  inUse = 0 where clientid = 430;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('380','06095', '150420', '5', '13749', '1', '225', '225', '0', '', '1', '2024-12-20 16:18:53', '13749', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','225','225','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 456.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 456.00
        
                where sellbilldetailid = 549567;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13749, '2024-12-20', 225, 380, 380
                    , 456, 380, 456, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+456
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+456
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 225, 380, 380
                    , 456, 380, 456, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+456
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+456
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '13748';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13749', '1', '1', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 16:18:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 30184;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('270','06063', '150420', '5', '13528', '2', '190', '380', '0', '', '1', '2024-12-20 16:18:53', '13528', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30184-2,','1','1','0','0','190','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 270.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 270.00, meanbuyprice_withDiscount = 270.00
        
                where sellbilldetailid = 549568;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13528, '2024-12-20', 380, 540, 540
                    , 540, 540, 540, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+540
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+540
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 380, 540, 540
                    , 540, 540, 540, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+540
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+540
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '13527';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13528', '1', '2', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '2', '75', '2024-12-20 16:18:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('380','B1134', '150420', '2', '13208', '1', '155', '155', '0', '', '1', '2024-12-20 16:18:53', '13208', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 382.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 382.00
        
                where sellbilldetailid = 549569;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13208, '2024-12-20', 155, 380, 380
                    , 382, 380, 382, 382.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+382
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+382
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+382.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 380, 380
                    , 382, 380, 382, 382.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+382
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+382
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+382.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '13207';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13208', '1', '1', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-20 16:18:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('135','05161', '150420', '5', '11180', '1', '110', '110', '0', '', '1', '2024-12-20 16:18:53', '11180', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','110','110','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 133.00 , meanbuyprice = 92.00, lastbuyprice_withDiscount = 135.00, meanbuyprice_withDiscount = 92.00
        , lastbuyprice_withTax = 133, meanbuyprice_withTax = 84
                where sellbilldetailid = 549570;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11180, '2024-12-20', 110, 135, 133
                    , 92, 135, 92, 133.31
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 133, 84, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+110, sellCostBuyPrice =sellCostBuyPrice+135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+133, sellCostMeanBuyPrice = sellCostMeanBuyPrice+92
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+92
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+133.31
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+133
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+84
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 110, 135, 133
                    , 92, 135, 92, 133.31
                    , 0, 0, 0, 0
                    , 0, 0, 0, 133, 84, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+110, sellCostBuyPrice =sellCostBuyPrice+135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+133, sellCostMeanBuyPrice = sellCostMeanBuyPrice+92
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+92
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+133.31
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+133
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+84
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-5', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '11179';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11180', '1', '1', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-4', '-5', '75', '2024-12-20 16:18:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 28672;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','S1157', '150420', '3', '12568', '1', '155', '155', '0', '', '1', '2024-12-20 16:18:53', '12568', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','28672-1,','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        
                where sellbilldetailid = 549571;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12568, '2024-12-20', 155, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '12567';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12568', '1', '1', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 16:18:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32309;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('220','06356', '150420', '5', '14527', '1', '165', '165', '0', '', '1', '2024-12-20 16:18:53', '14527', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32309-1,','1','1','0','0','165','165','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 260.00
        
                where sellbilldetailid = 549572;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14527, '2024-12-20', 165, 220, 220
                    , 260, 220, 260, 222.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+222.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 165, 220, 220
                    , 260, 220, 260, 222.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+222.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '14526';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14527', '1', '1', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 16:18:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29777;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('410','S1234', '150420', '3', '13296', '1', '185', '185', '0', '', '1', '2024-12-20 16:18:53', '13296', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29777-1,','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
        
                where sellbilldetailid = 549573;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13296, '2024-12-20', 185, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 185, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '13295';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13296', '1', '1', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-20 16:18:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32064;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06343', '150420', '5', '14424', '1', '155', '155', '0', '', '1', '2024-12-20 16:18:53', '14424', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32064-1,','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 466.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 466.00
        
                where sellbilldetailid = 549574;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14424, '2024-12-20', 155, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '14423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14424', '1', '1', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 16:18:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32011;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('220','06318', '150420', '5', '14390', '1', '120', '120', '0', '', '1', '2024-12-20 16:18:53', '14390', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32011-1,','1','1','0','0','120','120','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
        
                where sellbilldetailid = 549575;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14390, '2024-12-20', 120, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 120, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '14389';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14390', '1', '1', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-20 16:18:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('195','0K731', '150420', '7', '14263', '1', '120', '120', '0', '', '1', '2024-12-20 16:18:53', '14263', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','120','120','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 195.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 195.00
        
                where sellbilldetailid = 549576;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14263, '2024-12-20', 120, 195, 195
                    , 195, 195, 195, 195
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+195
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 120, 195, 195
                    , 195, 195, 195, 195
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+195
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '14262';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14263', '1', '1', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '75', '2024-12-20 16:18:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','06036', '150420', '5', '13503', '1', '185', '185', '0', '', '1', '2024-12-20 16:18:53', '13503', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        
                where sellbilldetailid = 549577;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13503, '2024-12-20', 185, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 185, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-5', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '13502';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13503', '1', '1', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-4', '-5', '75', '2024-12-20 16:18:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('300','S1283', '150420', '3', '14062', '1', '165', '165', '0', '', '1', '2024-12-20 16:18:53', '14062', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','165','165','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        
                where sellbilldetailid = 549578;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14062, '2024-12-20', 165, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 165, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '14061';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14062', '1', '1', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 16:18:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('180','عرض 180', '150420', '18', '10349', '3', '185', '555', '0', '', '1', '2024-12-20 16:18:53', '10349', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','185','555','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
        
                where sellbilldetailid = 549579;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10349, '2024-12-20', 555, 540, 540
                    , 540, 540, 540, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+555, sellCostBuyPrice =sellCostBuyPrice+540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+540
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+540
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 555, 540, 540
                    , 540, 540, 540, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+555, sellCostBuyPrice =sellCostBuyPrice+540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+540
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+540
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-7', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '10348';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10349', '1', '3', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-4', '-7', '75', '2024-12-20 16:18:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('60','عرض 60', '150420', '18', '10343', '3', '60', '180', '0', '', '1', '2024-12-20 16:18:53', '10343', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','60','180','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 60.00 , meanbuyprice = 60.00, lastbuyprice_withDiscount = 60.00, meanbuyprice_withDiscount = 60.00
        
                where sellbilldetailid = 549580;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10343, '2024-12-20', 180, 180, 180
                    , 180, 180, 180, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 180, 180, 180
                    , 180, 180, 180, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-18', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '10342';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10343', '1', '3', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-15', '-18', '75', '2024-12-20 16:18:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('90','عرض 90', '150420', '18', '10344', '4', '90', '360', '0', '', '1', '2024-12-20 16:18:53', '10344', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','90','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 90.00 , meanbuyprice = 90.00, lastbuyprice_withDiscount = 90.00, meanbuyprice_withDiscount = 90.00
        
                where sellbilldetailid = 549581;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10344, '2024-12-20', 360, 360, 360
                    , 360, 360, 360, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 4, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+4
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 360, 360
                    , 360, 360, 360, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-10', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '10343';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10344', '1', '4', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-6', '-10', '75', '2024-12-20 16:18:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('125','عرض 125', '150420', '18', '10350', '1', '125', '125', '0', '', '1', '2024-12-20 16:18:53', '10350', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','125','125','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 125.00 , meanbuyprice = 125.00, lastbuyprice_withDiscount = 125.00, meanbuyprice_withDiscount = 125.00
        
                where sellbilldetailid = 549582;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10350, '2024-12-20', 125, 125, 125
                    , 125, 125, 125, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 125, 125, 125
                    , 125, 125, 125, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-28', userid = '75', storedetaildate = '2024-12-20 16:18:53' WHERE storedetailid = '10349';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10350', '1', '1', '1', '150420', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-27', '-28', '75', '2024-12-20 16:18:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150420', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 16:18:53', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150420', '17', '10291', '1', '34', '34', '0', '', '1', '2024-12-20 16:18:54', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','34','34','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 86 where clientid = 430;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 3394, 4910, 4908
                    , 5226, 4910, 5226, 3708.31
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,133, 84, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3394, sellCostBuyPrice =sellCostBuyPrice+4910
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4908, sellCostMeanBuyPrice = sellCostMeanBuyPrice+5226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4910, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+5226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3708.31
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+133
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+84
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (430, '2024-12-20', 3394, 4910, 4908
                    , 5226, 4910, 5226, 3708.31
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,133, 84, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3394, sellCostBuyPrice =sellCostBuyPrice+4910
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4908, sellCostMeanBuyPrice = sellCostMeanBuyPrice+5226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4910, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+5226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3708.31
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+133
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+84
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3394, 4910, 4908
                    , 5226, 4910, 5226, 3708.31, 133, 84)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3394, netSellCostBuyPrice = netSellCostBuyPrice+4910
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+4908
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+5226
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+4910
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+5226
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+3708.31
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+133
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+84;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676579e3a3e4c and sellbillId = 150420 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:48:54";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:18:54", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:18:54', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:49:30";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:19:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:19:30', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247967
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10719,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '26' , clientdate = '2024-12-20 16:19:30', userid = '104' WHERE clientid = '10719';
UPDATE client SET  inUse = 0 where clientid = 10719;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10719','296.00','270','1','ايصال تحصيل (( قبض من عميل ))','247967', '26', '2024-12-20 16:18:14', '104', 'clientPayedDeptController.php', '   ', '270', '0', null, '0', null, null,'', '-1','1','1','270','1','','3645','0');
UPDATE save SET  savecurrentvalue = '27380',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('27110.00','270', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '247968', '27380', '2024-12-20 16:19:30', '104',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '270', '270', '2024-12-20', '104', '0', '0', '2024-12-20 16:19:30','اضافة ايصال سداد للعميل سلمي وحيد 12','1','0','-1','0','247968','clientPayedDeptController.php?do=show&id=247968');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122307', '-1', '270', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '270', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122307', '12497', '270', '','0');
UPDATE accountstree SET name = 'سلمي وحيد 12', customName = 'سلمي وحيد 12', customNameEn = 'سلمي وحيد 12', nameEn = 'سلمي وحيد 12', parent = '58', accountNature = '0', theValue = '-570', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-16 16:32:34' WHERE id = '12497';
UPDATE clientdebtchange SET clientid = '10719', clientdebtchangebefore = '296.000', clientdebtchangeamount = '270.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247967', clientdebtchangeafter = '26.000', clientdebtchangedate = '2024-12-20 16:18:14', userid = '104', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '270.00',discount='', reciptid='0', dailyentryid = '122307',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='270',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247968';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247967 -clientdebtchangeId = 247968
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:49:30";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:19:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:19:30', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:49:32";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:19:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:19:32', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:49:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:19:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:19:46', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657cf480f73
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:19:32', '067657cf480f73', '1', '0.00', '0', '0', '1', '310.00', '310', '310', '0', '1', '2024-12-20 16:19:46', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','310','0','','0','0','310','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150421', '0', '2024-12-20 16:19:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '310', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:19:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35974;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('285','07241', '150421', '5', '16321', '1', '310', '310', '0', '', '1', '2024-12-20 16:19:46', '16321', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35974-1,','1','1','0','0','310','310','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 285.00 , meanbuyprice = 285.00, lastbuyprice_withDiscount = 285.00, meanbuyprice_withDiscount = 285.00
        , lastbuyprice_withTax = 285, meanbuyprice_withTax = 285, lastbuyprice_withDiscountAndTax = 285
                where sellbilldetailid = 549585;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16321, '2024-12-20', 310, 285, 285
                    , 285, 285, 285, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 285, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+285
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+285
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+285
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+285
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 310, 285, 285
                    , 285, 285, 285, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0, 285, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+285
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+285
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+285
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+285
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '104', storedetaildate = '2024-12-20 16:19:46' WHERE storedetailid = '16320';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16321', '1', '1', '1', '150421', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-20 16:19:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '27690',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('27380','310', '0', '1', 'اضافة فاتورة مبيعات', '150421', '27690', '2024-12-20 16:19:46', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 310, 285, 285
                    , 285, 285, 285, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,285, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+285
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+285
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+285
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+285
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 310, 285, 285
                    , 285, 285, 285, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,285, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+285
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+285
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+285
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+285
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 310, 285, 285
                    , 285, 285, 285, 285, 285, 285)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+310, netSellCostBuyPrice = netSellCostBuyPrice+285
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+285
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+285
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+285
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+285
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+285
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+285
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+285;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657cf480f73 and sellbillId = 150421 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:49:47";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:19:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:19:47', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:51:25";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:21:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:21:25', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:52:07";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:22:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:22:07', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247970
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10650,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 16:22:07', userid = '104' WHERE clientid = '10650';
UPDATE client SET  inUse = 0 where clientid = 10650;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10650','260.00','260','1','ايصال تحصيل (( قبض من عميل ))','247970', '0', '2024-12-20 16:21:25', '104', 'clientPayedDeptController.php', '   ', '260', '0', null, '0', null, null,'', '-1','1','1','260','1','','3646','0');
UPDATE save SET  savecurrentvalue = '27950',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('27690.00','260', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '247970', '27950', '2024-12-20 16:22:07', '104',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '260', '260', '2024-12-20', '104', '0', '0', '2024-12-20 16:22:07','اضافة ايصال سداد للعميل عمرو محاسب برادا','1','0','-1','0','247970','clientPayedDeptController.php?do=show&id=247970');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122308', '-1', '260', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '260', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122308', '12333', '260', '','0');
UPDATE accountstree SET name = 'عمرو محاسب برادا', customName = 'عمرو محاسب برادا', customNameEn = 'عمرو محاسب برادا', nameEn = 'عمرو محاسب برادا', parent = '58', accountNature = '0', theValue = '-1500', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '104', del = '0', sysdate = '2024-12-09 18:23:16' WHERE id = '12333';
UPDATE clientdebtchange SET clientid = '10650', clientdebtchangebefore = '260.000', clientdebtchangeamount = '260.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247970', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 16:21:25', userid = '104', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '260.00',discount='', reciptid='0', dailyentryid = '122308',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='260',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247970';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247970 -clientdebtchangeId = 247970
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:52:07";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:22:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:22:07', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:52:09";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:22:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:22:09', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:52:13";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:22:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:22:13', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:52:48";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:22:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:22:48', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657d0335921
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:19:47', '067657d0335921', '1', '0.00', '0', '0', '1', '480.00', '480', '480', '0', '1', '2024-12-20 16:22:48', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','480','0','','0','0','480','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150422', '0', '2024-12-20 16:22:48', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '480', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:19:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36519;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('400','H1687', '150422', '14', '16498', '1', '480', '480', '0', '', '1', '2024-12-20 16:22:48', '16498', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36519-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549586;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16498, '2024-12-20', 480, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 480, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '19', userid = '104', storedetaildate = '2024-12-20 16:22:48' WHERE storedetailid = '16497';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16498', '1', '1', '1', '150422', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '104', '2024-12-20 16:22:48','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '28430',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('27950','480', '0', '1', 'اضافة فاتورة مبيعات', '150422', '28430', '2024-12-20 16:22:48', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 480, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 480, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 480, 400, 400
                    , 400, 400, 400, 400, 400, 400)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+480, netSellCostBuyPrice = netSellCostBuyPrice+400
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+400
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+400
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+400
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+400
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+400
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+400
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+400;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657d0335921 and sellbillId = 150422 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:52:49";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:22:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:22:49', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:53:22";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:23:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:23:22', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657d959e56a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:22:13', '067657d959e56a', '1', '0.00', '0', '0', '1', '780.00', '780', '780', '0', '1', '2024-12-20 16:23:22', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','780','0','','0','0','780','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150423', '0', '2024-12-20 16:23:22', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '780', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:22:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36249;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','06861', '150423', '5', '15635', '1', '300', '300', '0', '', '1', '2024-12-20 16:23:22', '15635', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36249-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 241, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549587;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15635, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 236.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 241, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+236.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+241
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 236.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 241, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+236.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+241
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '104', storedetaildate = '2024-12-20 16:23:22' WHERE storedetailid = '15634';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15635', '1', '1', '1', '150423', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-20 16:23:22','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36114;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('420','07037', '150423', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-20 16:23:22', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36114-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 549588;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15995, '2024-12-20', 480, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 480, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '51', userid = '104', storedetaildate = '2024-12-20 16:23:22' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '150423', 'اضافة فاتورة مبيعات', 'sellbillController.php', '52', '51', '104', '2024-12-20 16:23:22','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '29210',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('28430','780', '0', '1', 'اضافة فاتورة مبيعات', '150423', '29210', '2024-12-20 16:23:22', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 780, 660, 660
                    , 660, 660, 660, 656.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,660, 661, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+656.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+660
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+661
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 780, 660, 660
                    , 660, 660, 660, 656.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,660, 661, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+656.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+660
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+661
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 780, 660, 660
                    , 660, 660, 660, 656.67, 660, 661)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+780, netSellCostBuyPrice = netSellCostBuyPrice+660
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+660
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+660
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+660
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+660
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+656.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+660
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+661;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657d959e56a and sellbillId = 150423 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:53:22";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:23:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:23:22', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:54:04";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:24:04", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 16:24:04', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:54:10";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:24:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 16:24:10', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:54:14";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:24:14", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:24:14', '77', 'details', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=details&id=13992');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:54:18";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:24:18", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:24:18', '77', 'details', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=details&id=14108');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:54:24";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:24:24", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:24:24', '77', 'details', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=details&id=13836');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:56:22";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:26:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:26:22', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657db96d8c6
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:22:49', '067657db96d8c6', '1', '0.00', '0', '0', '1', '570.00', '570', '570', '0', '1', '2024-12-20 16:26:23', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','570','0','','0','0','570','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150424', '0', '2024-12-20 16:26:23', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '570', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:22:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36322;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('495','07287', '150424', '5', '16418', '1', '570', '570', '0', '', '1', '2024-12-20 16:26:23', '16418', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36322-1,','1','1','0','0','570','570','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 495.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 495.00
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 495, lastbuyprice_withDiscountAndTax = 495
                where sellbilldetailid = 549589;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16418, '2024-12-20', 570, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+570, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+495
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 570, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+570, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+495
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '104', storedetaildate = '2024-12-20 16:26:23' WHERE storedetailid = '16417';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16418', '1', '1', '1', '150424', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '104', '2024-12-20 16:26:23','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '29780',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('29210','570', '0', '1', 'اضافة فاتورة مبيعات', '150424', '29780', '2024-12-20 16:26:23', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 570, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+570, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+495
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 570, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+570, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+495
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 570, 495, 495
                    , 495, 495, 495, 495, 495, 495)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+570, netSellCostBuyPrice = netSellCostBuyPrice+495
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+495
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+495
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+495
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+495
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+495
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+495
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+495;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657db96d8c6 and sellbillId = 150424 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:56:23";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:26:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:26:23', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:56:42";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:26:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:26:42', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247966
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7701,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '2' , clientdate = '2024-12-20 16:26:42', userid = '2' WHERE clientid = '7701';
UPDATE client SET  inUse = 0 where clientid = 7701;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7701','602.00','600','1','ايصال تحصيل (( قبض من عميل ))','247966', '2', '2024-12-20 16:17:33', '2', 'clientPayedDeptController.php', '   ', '600', '0', null, '0', null, null,'', '-1','1','1','600','1','','3645','0');
UPDATE save SET  savecurrentvalue = '131542.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('130942.50','600', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247974', '131542.5', '2024-12-20 16:26:42', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '600', '600', '2024-12-20', '2', '0', '0', '2024-12-20 16:26:42','اضافة ايصال سداد للعميل الهام جمال Z1102','1','0','0','0','247974','clientPayedDeptController.php?do=show&id=247974');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122309', '-1', '600', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '600', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122309', '-1', '600', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-600', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '7701', clientdebtchangebefore = '602.000', clientdebtchangeamount = '600.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247966', clientdebtchangeafter = '2.000', clientdebtchangedate = '2024-12-20 16:17:33', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '600.00',discount='', reciptid='0', dailyentryid = '122309',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='600',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247974';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247966 -clientdebtchangeId = 247974
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:56:43";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:26:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:26:43', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:57:06";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:27:06", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:27:06', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:57:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:27:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:27:38', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247975
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10746,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-1' , clientdate = '2024-12-20 16:27:38', userid = '2' WHERE clientid = '10746';
UPDATE client SET  inUse = 0 where clientid = 10746;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10746','1919.00','1920','1','ايصال تحصيل (( قبض من عميل ))','247975', '-1', '2024-12-20 16:26:43', '2', 'clientPayedDeptController.php', '   ', '1920', '0', null, '0', null, null,'', '-1','1','1','1920','1','','3647','0');
UPDATE save SET  savecurrentvalue = '133462.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('131542.50','1920', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247975', '133462.5', '2024-12-20 16:27:38', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1920', '1920', '2024-12-20', '2', '0', '0', '2024-12-20 16:27:38','اضافة ايصال سداد للعميل شذي محمد 25','1','0','0','0','247975','clientPayedDeptController.php?do=show&id=247975');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122310', '-1', '1920', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1920', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122310', '12568', '1920', '','0');
UPDATE accountstree SET name = 'شذي محمد 25', customName = 'شذي محمد 25', customNameEn = 'شذي محمد 25', nameEn = 'شذي محمد 25', parent = '58', accountNature = '0', theValue = '-1920', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-19 11:45:54' WHERE id = '12568';
UPDATE clientdebtchange SET clientid = '10746', clientdebtchangebefore = '1919.000', clientdebtchangeamount = '1920.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247975', clientdebtchangeafter = '-1.000', clientdebtchangedate = '2024-12-20 16:26:43', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1920.00',discount='', reciptid='0', dailyentryid = '122310',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1920',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247975';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247975 -clientdebtchangeId = 247975
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:57:39";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:27:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:27:39', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:58:01";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:28:01", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:28:01', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657ccec30fb
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1236,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:18:54', '067657ccec30fb', '1236', '0.00', '4434', '0', '1', '4434.00', '4434', '0', '4434', '1', '2024-12-20 16:28:01', '', '75', '0', 'ايمان محمد القناطر 14', '2', '1', '3', '98', 'ايمان محمد القناطر 14', '14' ,'0','','','','','-1','0','0','0','0','0','4434','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '4434', userid = '75' WHERE clientid = '1236';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1236','0.00','4434','0','اضافة فاتورة مبيعات','150425', '4434', '2024-12-20 16:28:01', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '4434', '0', null, '0', null, null,'', '0','1','1','4434','1','2024-12-20 16:18:54','0','0');
UPDATE client SET  inUse = 0 where clientid = 1236;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('595','H1400', '150425', '14', '15652', '1', '650', '650', '0', '', '1', '2024-12-20 16:28:01', '15652', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 595.00 , meanbuyprice = 595.00, lastbuyprice_withDiscount = 595.00, meanbuyprice_withDiscount = 595.00
        , lastbuyprice_withTax = 595, meanbuyprice_withTax = 595, lastbuyprice_withDiscountAndTax = 595
                where sellbilldetailid = 549590;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15652, '2024-12-20', 650, 595, 595
                    , 595, 595, 595, 595
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 595, 595, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+595
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+595, sellCostMeanBuyPrice = sellCostMeanBuyPrice+595
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+595, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+595
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+595
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+595
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+595
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 650, 595, 595
                    , 595, 595, 595, 595
                    , 0, 0, 0, 0
                    , 0, 0, 0, 595, 595, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+595
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+595, sellCostMeanBuyPrice = sellCostMeanBuyPrice+595
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+595, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+595
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+595
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+595
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+595
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-7', userid = '75', storedetaildate = '2024-12-20 16:28:01' WHERE storedetailid = '15651';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15652', '1', '1', '1', '150425', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-6', '-7', '75', '2024-12-20 16:28:01','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','06446', '150425', '5', '14688', '3', '220', '660', '0', '', '1', '2024-12-20 16:28:01', '14688', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','220','660','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 549591;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14688, '2024-12-20', 660, 750, 750
                    , 750, 750, 750, 750
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+660, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+750, sellCostMeanBuyPrice = sellCostMeanBuyPrice+750
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+750, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+750
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+750
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 660, 750, 750
                    , 750, 750, 750, 750
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+660, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+750, sellCostMeanBuyPrice = sellCostMeanBuyPrice+750
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+750, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+750
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+750
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 16:28:01' WHERE storedetailid = '14687';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14688', '1', '3', '1', '150425', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '2', '75', '2024-12-20 16:28:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35252;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('170','06961', '150425', '5', '15869', '1', '240', '240', '0', '', '1', '2024-12-20 16:28:01', '15869', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35252-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 134, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 549592;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15869, '2024-12-20', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 170, 134, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+134
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 134, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+134
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 16:28:01' WHERE storedetailid = '15868';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15869', '1', '1', '1', '150425', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 16:28:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36186;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('455','07276', '150425', '5', '16391', '1', '510', '510', '0', '', '1', '2024-12-20 16:28:01', '16391', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36186-1,','1','1','0','0','510','510','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 455.00 , meanbuyprice = 455.00, lastbuyprice_withDiscount = 455.00, meanbuyprice_withDiscount = 455.00
        , lastbuyprice_withTax = 455, meanbuyprice_withTax = 455, lastbuyprice_withDiscountAndTax = 455
                where sellbilldetailid = 549593;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16391, '2024-12-20', 510, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+455
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+455, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+455, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+455
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+455
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+455
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 510, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+455
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+455, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+455, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+455
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+455
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+455
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '75', storedetaildate = '2024-12-20 16:28:01' WHERE storedetailid = '16390';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16391', '1', '1', '1', '150425', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-20 16:28:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36003;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07220', '150425', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-20 16:28:02', '16293', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36003-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549594;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16293, '2024-12-20', 200, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '31', userid = '75', storedetaildate = '2024-12-20 16:28:02' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '150425', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32', '31', '75', '2024-12-20 16:28:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35989;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('230','07244', '150425', '5', '16334', '1', '280', '280', '0', '', '1', '2024-12-20 16:28:02', '16334', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35989-1,','1','1','0','0','280','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where sellbilldetailid = 549595;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16334, '2024-12-20', 280, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 280, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '21', userid = '75', storedetaildate = '2024-12-20 16:28:02' WHERE storedetailid = '16333';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16334', '1', '1', '1', '150425', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '75', '2024-12-20 16:28:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36008;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('425','H1640', '150425', '14', '16340', '1', '500', '500', '0', '', '1', '2024-12-20 16:28:02', '16340', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36008-1,','1','1','0','0','500','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 425.00 , meanbuyprice = 425.00, lastbuyprice_withDiscount = 425.00, meanbuyprice_withDiscount = 425.00
        , lastbuyprice_withTax = 425, meanbuyprice_withTax = 213, lastbuyprice_withDiscountAndTax = 425
                where sellbilldetailid = 549596;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16340, '2024-12-20', 500, 425, 425
                    , 425, 425, 425, 425
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 425, 213, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+425
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+425
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+425
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+425
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+213
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 500, 425, 425
                    , 425, 425, 425, 425
                    , 0, 0, 0, 0
                    , 0, 0, 0, 425, 213, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+425
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+425
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+425
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+425
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+213
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '75', storedetaildate = '2024-12-20 16:28:02' WHERE storedetailid = '16339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16340', '1', '1', '1', '150425', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-20 16:28:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36418;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('340','H1667', '150425', '14', '16404', '1', '420', '420', '0', '', '1', '2024-12-20 16:28:02', '16404', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36418-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 340.00 , meanbuyprice = 340.00, lastbuyprice_withDiscount = 340.00, meanbuyprice_withDiscount = 340.00
        , lastbuyprice_withTax = 340, meanbuyprice_withTax = 340, lastbuyprice_withDiscountAndTax = 340
                where sellbilldetailid = 549597;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16404, '2024-12-20', 420, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+340
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+340
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '75', storedetaildate = '2024-12-20 16:28:02' WHERE storedetailid = '16403';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16404', '1', '1', '1', '150425', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-20 16:28:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35791;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('500','H1604', '150425', '14', '16233', '1', '600', '600', '0', '', '1', '2024-12-20 16:28:02', '16233', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35791-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 500.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 500.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 500, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 549598;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16233, '2024-12-20', 600, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+500
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+500
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '75', storedetaildate = '2024-12-20 16:28:02' WHERE storedetailid = '16232';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16233', '1', '1', '1', '150425', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-20 16:28:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29854;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('260','05891', '150425', '5', '13153', '1', '310', '310', '0', '', '1', '2024-12-20 16:28:02', '13153', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29854-1,','1','1','0','0','310','310','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 565.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 565.00
        
                where sellbilldetailid = 549599;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13153, '2024-12-20', 310, 260, 260
                    , 565, 260, 565, 259.47
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+565
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+565
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.47
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 310, 260, 260
                    , 565, 260, 565, 259.47
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+565
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+565
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.47
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '36', userid = '75', storedetaildate = '2024-12-20 16:28:02' WHERE storedetailid = '13152';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13153', '1', '1', '1', '150425', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37', '36', '75', '2024-12-20 16:28:02','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150425', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 16:28:02', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150425', '17', '10291', '1', '44', '44', '0', '', '1', '2024-12-20 16:28:02', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','44','44','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 98 where clientid = 1236;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 4434, 3880, 3880
                    , 4185, 3880, 4185, 3879.47
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2870, 2622, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4434, sellCostBuyPrice =sellCostBuyPrice+3880
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3880, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3880, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3879.47
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2622
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1236, '2024-12-20', 4434, 3880, 3880
                    , 4185, 3880, 4185, 3879.47
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2870, 2622, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4434, sellCostBuyPrice =sellCostBuyPrice+3880
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3880, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3880, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3879.47
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2622
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 4434, 3880, 3880
                    , 4185, 3880, 4185, 3879.47, 2870, 2622)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+4434, netSellCostBuyPrice = netSellCostBuyPrice+3880
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3880
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+4185
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3880
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+4185
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+3879.47
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2870
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2622;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657ccec30fb and sellbillId = 150425 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:58:02";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:28:02", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:28:02', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:58:08";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:28:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:28:08', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657ddb09516
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9375,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:23:23', '067657ddb09516', '9375', '0.00', '1091', '0', '1', '1091.00', '1091', '0', '1091', '1', '2024-12-20 16:28:08', '', '104', '0', 'ياسمين فتحي T659', '1', '1', '3', '25', 'ياسمين فتحي T659', '4' ,'0','','','','','-1','0','0','0','0','0','1091','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1091', userid = '104' WHERE clientid = '9375';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9375','0.00','1091','0','اضافة فاتورة مبيعات','150426', '1091', '2024-12-20 16:28:08', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1091', '0', null, '0', null, null,'', '0','1','1','1091','1','2024-12-20 16:23:23','0','0');
UPDATE client SET  inUse = 0 where clientid = 9375;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36159;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('585','H1644', '150426', '14', '16388', '1', '700', '700', '0', '', '1', '2024-12-20 16:28:08', '16388', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36159-1,','1','1','0','0','700','700','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 585.00 , meanbuyprice = 585.00, lastbuyprice_withDiscount = 585.00, meanbuyprice_withDiscount = 585.00
        , lastbuyprice_withTax = 585, meanbuyprice_withTax = 585, lastbuyprice_withDiscountAndTax = 585
                where sellbilldetailid = 549602;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16388, '2024-12-20', 700, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+585
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+585
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 700, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0, 585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+585
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+585
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '104', storedetaildate = '2024-12-20 16:28:08' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '1', '1', '150426', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-20 16:28:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36331;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','06675', '150426', '5', '15165', '2', '190', '380', '0', '', '1', '2024-12-20 16:28:08', '15165', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36331-2,','1','1','0','0','190','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549603;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15165, '2024-12-20', 380, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 380, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-12', userid = '104', storedetaildate = '2024-12-20 16:28:08' WHERE storedetailid = '15164';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15165', '1', '2', '1', '150426', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-10', '-12', '104', '2024-12-20 16:28:08','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150426', '17', '10291', '1', '11', '11', '0', '', '1', '2024-12-20 16:28:08', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','11','11','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 25 where clientid = 9375;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1091, 865, 865
                    , 865, 865, 865, 865
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,865, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1091, sellCostBuyPrice =sellCostBuyPrice+865
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+865, sellCostMeanBuyPrice = sellCostMeanBuyPrice+865
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+865, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+865
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+865
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+865
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+585
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9375, '2024-12-20', 1091, 865, 865
                    , 865, 865, 865, 865
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,865, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1091, sellCostBuyPrice =sellCostBuyPrice+865
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+865, sellCostMeanBuyPrice = sellCostMeanBuyPrice+865
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+865, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+865
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+865
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+865
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+585
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1091, 865, 865
                    , 865, 865, 865, 865, 865, 585)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1091, netSellCostBuyPrice = netSellCostBuyPrice+865
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+865
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+865
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+865
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+865
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+865
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+865
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+585;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657ddb09516 and sellbillId = 150426 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:58:09";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:28:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:28:09', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:58:36";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:28:36", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:28:36', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247976
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7370,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '864' , clientdate = '2024-12-20 16:28:36', userid = '2' WHERE clientid = '7370';
UPDATE client SET  inUse = 0 where clientid = 7370;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7370','1364.00','500','1','ايصال تحصيل (( قبض من عميل ))','247976', '864', '2024-12-20 16:27:39', '2', 'clientPayedDeptController.php', '   ', '500', '0', null, '0', null, null,'', '-1','1','1','500','1','','3648','0');
UPDATE save SET  savecurrentvalue = '133962.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('133462.50','500', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247978', '133962.5', '2024-12-20 16:28:36', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '500', '500', '2024-12-20', '2', '0', '0', '2024-12-20 16:28:36','اضافة ايصال سداد للعميل شيماء جبريل W76','1','0','0','0','247978','clientPayedDeptController.php?do=show&id=247978');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122311', '-1', '500', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '500', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122311', '-1', '500', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-500', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '7370', clientdebtchangebefore = '1364.000', clientdebtchangeamount = '500.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247976', clientdebtchangeafter = '864.000', clientdebtchangedate = '2024-12-20 16:27:39', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '500.00',discount='', reciptid='0', dailyentryid = '122311',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='500',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247978';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247976 -clientdebtchangeId = 247978
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:58:37";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:28:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:28:37', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:58:55";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:28:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:28:55', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247979
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10765,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '79' , clientdate = '2024-12-20 16:28:55', userid = '2' WHERE clientid = '10765';
UPDATE client SET  inUse = 0 where clientid = 10765;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10765','2369.00','2290','1','ايصال تحصيل (( قبض من عميل ))','247979', '79', '2024-12-20 16:28:37', '2', 'clientPayedDeptController.php', '   ', '2290', '0', null, '0', null, null,'', '-1','1','1','2290','1','','3649','0');
UPDATE save SET  savecurrentvalue = '136252.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('133962.50','2290', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247979', '136252.5', '2024-12-20 16:28:55', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '2290', '2290', '2024-12-20', '2', '0', '0', '2024-12-20 16:28:55','اضافة ايصال سداد للعميل مكة احمد 25','1','0','0','0','247979','clientPayedDeptController.php?do=show&id=247979');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122312', '-1', '2290', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '2290', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122312', '12606', '2290', '','0');
UPDATE accountstree SET name = 'مكة احمد 25', customName = 'مكة احمد 25', customNameEn = 'مكة احمد 25', nameEn = 'مكة احمد 25', parent = '58', accountNature = '0', theValue = '-2290', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-20 15:07:32' WHERE id = '12606';
UPDATE clientdebtchange SET clientid = '10765', clientdebtchangebefore = '2369.000', clientdebtchangeamount = '2290.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247979', clientdebtchangeafter = '79.000', clientdebtchangedate = '2024-12-20 16:28:37', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '2290.00',discount='', reciptid='0', dailyentryid = '122312',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='2290',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247979';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247979 -clientdebtchangeId = 247979
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:58:56";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:28:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:28:56', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('Y922','','4','250','250', '250','250', '2024-12-20', '0', '77', '1', '0Y922', '0', '0', '0', '0', '0', '250','250','250','250','250','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','250','250','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16525, 1,'2024-12-20 16:29:45',77)
                ON DUPLICATE KEY UPDATE productid = 16525, edited = 1, sysdate = '2024-12-20 16:29:45', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16525', '1', '2024-12-20', '77', '0','1652501','250','250','250','250','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16525', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16525', '1', '0', '0', '16525', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:59:58";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:29:58", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:29:58', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('067657ebb2376f', '2024-12-20 16:27:07', '186', '9725.00', '35975', '0', '0', '26250',  '26250', '0', '26250', '1', '2024-12-20 16:29:58', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1569', '14173', '14', '16178', '50', '375', '18750', '0', '', '2024-12-20 16:29:58', '16178','','','0','0','0','0','0',null,'375','18750','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:27:07', 1, 16178, 0, 0
                    , 375, 50, 0, 0, 77, '2024-12-20 16:29:58')
                ON DUPLICATE KEY UPDATE buyprice = 375,
                        buyQuantity =buyQuantity+50, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:29:58' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16178', '375', '50', '0', 'buyBillController.php', '32795', '', '0', '0');
UPDATE product SET  productBuyPrice = "375" WHERE productId = 16178 ;
UPDATE buybilldetail SET  quantitybefore = 4 WHERE buybilldetailid = 32795 ;
UPDATE product SET productName = 'H1569', productDescription = '', productCatId = '14', productBuyPrice = '375.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2024-11-28', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1569',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '375',lastbuyprice_withDiscount = '375',meanbuyprice = '375',meanbuyprice_withDiscount = '375' , productbuypricereal = '375.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='375',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='375',meanbuyprice_withTax='375',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='375'  WHERE productId = '16178';
UPDATE buybilldetail SET  lastbuyprice = 375 , meanbuyprice = 375, lastbuyprice_withDiscount = 375, meanbuyprice_withDiscount = 375
        , lastbuyprice_withTax = 375, meanbuyprice_withTax = 375, lastbuyprice_withDiscountAndTax = 375
                where buybilldetailid = 32795;
UPDATE productunit SET proUnitBuyPrice  = 375 * productnumber WHERE productid = 16178;
UPDATE storedetail SET  productquantity = '54', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16177';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16178', '1', '50', '0', '14173', 'اضافة فاتورة مشتريات', 'buyBillController.php', '4', '54', '77', '2024-12-20 16:27:07','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('0Y922', '14173', '4', '16525', '30', '250', '7500', '0', '', '2024-12-20 16:29:58', '16525','','','0','0','0','0','0',null,'250','7500','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:27:07', 1, 16525, 0, 0
                    , 250, 30, 0, 0, 77, '2024-12-20 16:29:58')
                ON DUPLICATE KEY UPDATE buyprice = 250,
                        buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:29:58' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16525', '250', '30', '0', 'buyBillController.php', '32796', '', '0', '0');
UPDATE product SET  productBuyPrice = "250" WHERE productId = 16525 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32796 ;
UPDATE product SET productName = 'Y922', productDescription = '', productCatId = '4', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '250.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '0Y922',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '250',lastbuyprice_withDiscount = '250',meanbuyprice = '250',meanbuyprice_withDiscount = '250' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='250',meanbuyprice_withTax='250',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='250'  WHERE productId = '16525';
UPDATE buybilldetail SET  lastbuyprice = 250 , meanbuyprice = 250, lastbuyprice_withDiscount = 250, meanbuyprice_withDiscount = 250
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where buybilldetailid = 32796;
UPDATE productunit SET proUnitBuyPrice  = 250 * productnumber WHERE productid = 16525;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16524';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16525', '1', '30', '0', '14173', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '30', '77', '2024-12-20 16:27:07','0','0');
UPDATE supplier SET  suppliercurrentDebt = '35975',suppliercurrentDebtInCurrency= '35975' , userid = '77', supplierdate = '2024-12-20 16:29:58'   WHERE supplierid = '186';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('186', '9725.00', '26250', '0', 'اضافة فاتورة مشتريات', '14173', '35975', '2024-12-20 16:27:07', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','26250','1','9725','26250','35975','0');
update buybill set dailyentryid='0,' where buybillid=14173;
COMMIT;
UPDATE product SET overAllAveragePrice = 375 WHERE productId = 16178;UPDATE product SET overAllAveragePrice = 250 WHERE productId = 16525;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 12:59:59";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:29:59", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:29:59', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14173');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:00:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:30:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:30:00', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247980
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10769,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 16:30:00', userid = '2' WHERE clientid = '10769';
UPDATE client SET  inUse = 0 where clientid = 10769;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10769','222.00','222','1','ايصال تحصيل (( قبض من عميل ))','247980', '0', '2024-12-20 16:28:56', '2', 'clientPayedDeptController.php', '   ', '222', '0', null, '0', null, null,'', '-1','1','1','222','1','','3650','0');
UPDATE save SET  savecurrentvalue = '136474.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('136252.50','222', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247980', '136474.5', '2024-12-20 16:30:00', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '222', '222', '2024-12-20', '2', '0', '0', '2024-12-20 16:30:00','اضافة ايصال سداد للعميل روان السويس 25','1','0','0','0','247980','clientPayedDeptController.php?do=show&id=247980');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122313', '-1', '222', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '222', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122313', '12610', '222', '','0');
UPDATE accountstree SET name = 'روان السويس 25', customName = 'روان السويس 25', customNameEn = 'روان السويس 25', nameEn = 'روان السويس 25', parent = '58', accountNature = '0', theValue = '-222', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-20 15:10:39' WHERE id = '12610';
UPDATE clientdebtchange SET clientid = '10769', clientdebtchangebefore = '222.000', clientdebtchangeamount = '222.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247980', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 16:28:56', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '222.00',discount='', reciptid='0', dailyentryid = '122313',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='222',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247980';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247980 -clientdebtchangeId = 247980
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:00:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:30:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:30:00', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:00:21";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:30:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:30:21', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247981
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(311,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 16:30:22', userid = '2' WHERE clientid = '311';
UPDATE client SET  inUse = 0 where clientid = 311;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('311','1586.00','1586','1','ايصال تحصيل (( قبض من عميل ))','247981', '0', '2024-12-20 16:30:00', '2', 'clientPayedDeptController.php', '   ', '1586', '0', null, '0', null, null,'', '-1','1','1','1586','1','','3651','0');
UPDATE save SET  savecurrentvalue = '138060.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('136474.50','1586', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247981', '138060.5', '2024-12-20 16:30:22', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1586', '1586', '2024-12-20', '2', '0', '0', '2024-12-20 16:30:22','اضافة ايصال سداد للعميل اسراء احمد K283','1','0','0','0','247981','clientPayedDeptController.php?do=show&id=247981');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122314', '-1', '1586', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1586', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122314', '-1', '1586', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1586', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '311', clientdebtchangebefore = '1586.000', clientdebtchangeamount = '1586.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247981', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 16:30:00', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1586.00',discount='', reciptid='0', dailyentryid = '122314',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1586',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247981';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247981 -clientdebtchangeId = 247981
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:00:22";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:30:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:30:22', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:00:44";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:30:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:30:44', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247982
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8520,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '21' , clientdate = '2024-12-20 16:30:44', userid = '2' WHERE clientid = '8520';
UPDATE client SET  inUse = 0 where clientid = 8520;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8520','1284.00','1263','1','ايصال تحصيل (( قبض من عميل ))','247982', '21', '2024-12-20 16:30:22', '2', 'clientPayedDeptController.php', '   ', '1263', '0', null, '0', null, null,'', '-1','1','1','1263','1','','3652','0');
UPDATE save SET  savecurrentvalue = '139323.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('138060.50','1263', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247982', '139323.5', '2024-12-20 16:30:44', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('شروق احمد T203', 'شروق احمد T203', 'شروق احمد T203', 'شروق احمد T203', '58', '0', '21.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 16:30:44');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1263', '1263', '2024-12-20', '2', '0', '0', '2024-12-20 16:30:44','اضافة ايصال سداد للعميل شروق احمد T203','1','0','0','0','247982','clientPayedDeptController.php?do=show&id=247982');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122315', '-1', '1263', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1263', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122315', '12616', '1263', '','0');
UPDATE accountstree SET name = 'شروق احمد T203', customName = 'شروق احمد T203', customNameEn = 'شروق احمد T203', nameEn = 'شروق احمد T203', parent = '58', accountNature = '0', theValue = '-1242', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 16:30:44' WHERE id = '12616';
UPDATE clientdebtchange SET clientid = '8520', clientdebtchangebefore = '1284.000', clientdebtchangeamount = '1263.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247982', clientdebtchangeafter = '21.000', clientdebtchangedate = '2024-12-20 16:30:22', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1263.00',discount='', reciptid='0', dailyentryid = '122315',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1263',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247982';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247982 -clientdebtchangeId = 247982
-- ----------------------------------------------------------------------------------------------------

INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('روان سامح 52' , '', '', '01149810154', '0', '', '0', '2024-12-20 16:30:45', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10773', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10773','0','0','0','إضافة عميل جديد','10773', '0', '2024-12-20 16:30:45', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:00:45";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:30:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:30:45', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('روان سامح 52', 'روان سامح 52', 'روان سامح 52', 'روان سامح 52', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-20 16:30:45');
UPDATE client SET clientname = 'روان سامح 52', clientaddress = '', clientphone = '', clientmobile = '01149810154', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '75'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12617',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10773';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:01:05";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:31:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:31:05', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657e8fdf162
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:26:23', '067657e8fdf162', '1', '0.00', '0', '0', '1', '125.00', '125', '125', '0', '1', '2024-12-20 16:31:05', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','125','0','','0','0','125','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150427', '0', '2024-12-20 16:31:05', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '125', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:26:23','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','06078', '150427', '5', '13753', '1', '125', '125', '0', '', '1', '2024-12-20 16:31:05', '13753', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','125','125','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        
                where sellbilldetailid = 549605;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13753, '2024-12-20', 125, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 125, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '104', storedetaildate = '2024-12-20 16:31:05' WHERE storedetailid = '13752';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13753', '1', '1', '1', '150427', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '104', '2024-12-20 16:31:05','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '29905',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('29780','125', '0', '1', 'اضافة فاتورة مبيعات', '150427', '29905', '2024-12-20 16:31:05', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 125, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 125, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 125, 155, 155
                    , 155, 155, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+125, netSellCostBuyPrice = netSellCostBuyPrice+155
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+155
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+155
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+155
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+155
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+155
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657e8fdf162 and sellbillId = 150427 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:01:06";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:31:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:31:06', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:01:09";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:31:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:31:10', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247984
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9375,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 16:31:10', userid = '2' WHERE clientid = '9375';
UPDATE client SET  inUse = 0 where clientid = 9375;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9375','1091.00','1091','1','ايصال تحصيل (( قبض من عميل ))','247984', '0', '2024-12-20 16:30:45', '2', 'clientPayedDeptController.php', '   ', '1091', '0', null, '0', null, null,'', '-1','1','1','1091','1','','3653','0');
UPDATE save SET  savecurrentvalue = '140414.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('139323.50','1091', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247985', '140414.5', '2024-12-20 16:31:10', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1091', '1091', '2024-12-20', '2', '0', '0', '2024-12-20 16:31:10','اضافة ايصال سداد للعميل ياسمين فتحي T659','1','0','0','0','247985','clientPayedDeptController.php?do=show&id=247985');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122316', '-1', '1091', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1091', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122316', '-1', '1091', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1091', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '9375', clientdebtchangebefore = '1091.000', clientdebtchangeamount = '1091.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247984', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 16:30:45', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1091.00',discount='', reciptid='0', dailyentryid = '122316',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1091',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247985';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247984 -clientdebtchangeId = 247985
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:01:10";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:31:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:31:10', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:01:27";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:31:27", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:31:27', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657ef315575
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10773,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:28:03', '067657ef315575', '10773', '0.00', '374', '0', '1', '374.00', '374', '0', '374', '1', '2024-12-20 16:31:28', '', '75', '0', 'روان سامح 52', '2', '1', '3', '98', 'روان سامح 52', '3' ,'0','','','','','-1','0','0','0','0','0','374','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '374', userid = '75' WHERE clientid = '10773';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10773','0.00','374','0','اضافة فاتورة مبيعات','150428', '374', '2024-12-20 16:31:28', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '374', '0', null, '0', null, null,'', '0','1','1','374','1','2024-12-20 16:28:03','0','0');
UPDATE client SET  inUse = 0 where clientid = 10773;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36456;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('280','07310', '150428', '5', '16468', '1', '350', '350', '0', '', '1', '2024-12-20 16:31:28', '16468', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36456-1,','1','1','0','0','350','350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 280, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 549606;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16468, '2024-12-20', 350, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 350, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '75', storedetaildate = '2024-12-20 16:31:28' WHERE storedetailid = '16467';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16468', '1', '1', '1', '150428', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-20 16:31:28','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150428', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 16:31:28', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150428', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-20 16:31:28', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','4','4','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 98 where clientid = 10773;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 374, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+374, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10773, '2024-12-20', 374, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+374, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 374, 280, 280
                    , 280, 280, 280, 280, 280, 280)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+374, netSellCostBuyPrice = netSellCostBuyPrice+280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+280
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+280
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+280
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+280
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+280;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657ef315575 and sellbillId = 150428 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:01:28";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:31:28", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:31:28', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:01:32";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:31:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:31:32', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657faab5e07
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:31:06', '067657faab5e07', '1', '0.00', '0', '0', '1', '500.00', '500', '500', '0', '1', '2024-12-20 16:31:32', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','500','0','','0','0','500','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150429', '0', '2024-12-20 16:31:32', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '500', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:31:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36008;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('425','H1640', '150429', '14', '16340', '1', '500', '500', '0', '', '1', '2024-12-20 16:31:32', '16340', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36008-1,','1','1','0','0','500','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 425.00 , meanbuyprice = 425.00, lastbuyprice_withDiscount = 425.00, meanbuyprice_withDiscount = 425.00
        , lastbuyprice_withTax = 425, meanbuyprice_withTax = 213, lastbuyprice_withDiscountAndTax = 425
                where sellbilldetailid = 549609;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16340, '2024-12-20', 500, 425, 425
                    , 425, 425, 425, 425
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 425, 213, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+425
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+425
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+425
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+425
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+213
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 500, 425, 425
                    , 425, 425, 425, 425
                    , 0, 0, 0, 0
                    , 0, 0, 0, 425, 213, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+425
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+425
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+425
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+425
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+213
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '104', storedetaildate = '2024-12-20 16:31:32' WHERE storedetailid = '16339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16340', '1', '1', '1', '150429', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-20 16:31:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '30405',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('29905','500', '0', '1', 'اضافة فاتورة مبيعات', '150429', '30405', '2024-12-20 16:31:32', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 97 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 500, 425, 425
                    , 425, 425, 425, 425
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,425, 213, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+425
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+425
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+425
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+425
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+213
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 500, 425, 425
                    , 425, 425, 425, 425
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,425, 213, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+425
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+425
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+425
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+425
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+213
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 500, 425, 425
                    , 425, 425, 425, 425, 425, 213)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+500, netSellCostBuyPrice = netSellCostBuyPrice+425
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+425
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+425
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+425
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+425
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+425
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+425
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+213;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657faab5e07 and sellbillId = 150429 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:01:32";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:31:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:31:32', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:02:33";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:32:33", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:32:33', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:03:09";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 16:33:09", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:33:09', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:03:14";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 16:33:14", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:33:14', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:03:29";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:33:29", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 16:33:29', '75', '', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:03:34";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 16:33:34", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:33:34', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:03:44";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:33:44", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:33:44', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('06765800213a99', '2024-12-20 16:32:34', '186', '35975.00', '28475', '0', '0', '-7500', '-7500', '0', '-7500', '1', '2024-12-20 16:33:44', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('0Y922', '2526', '4', '16525', '30', '250', '7500', '0', '', '16525','','','0','0','0','0','0','250','7500','0','0','0','0','0','0','0');
UPDATE product SET productName = 'Y922', productDescription = '', productCatId = '4', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '250.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '0Y922',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '250',lastbuyprice_withDiscount = '250',meanbuyprice = '250.00',meanbuyprice_withDiscount = '250' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='250',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='250',meanbuyprice_withTax='0',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='250'  WHERE productId = '16525';
UPDATE returnbuybilldetail SET  lastbuyprice = 250 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where returnbuybilldetailid = 3959;
UPDATE productunit SET proUnitBuyPrice  = 250 * productnumber WHERE productid = 16525;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16524';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16525', '1', '30', '1', '2526', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '30', '0', '77', '2024-12-20 16:32:34','0','0');
UPDATE supplier SET  suppliercurrentDebt = '28475',suppliercurrentDebtInCurrency= '28475' , userid = '77', supplierdate = '2024-12-20 16:33:44'   WHERE supplierid = '186';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('186', '35975.00', '7500', '1', 'اضافة فاتورة مردوات مشتريات', '2526', '28475', '2024-12-20 16:32:34', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','7500','1','35975','7500','28475','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2526;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:03:45";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:33:45", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 16:33:45', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2526');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:03:50";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:33:50", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 16:33:50', '75', 'show', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:03:53";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:33:53", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:33:53', '75', 'showDetail', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150417');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:03:56";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:33:56", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:33:56', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:04:12";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 16:34:12", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:34:12', '101', 'editsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150409');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:04:37";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:34:37", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 16:34:37', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:04:51";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:34:51", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:34:51', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:04:57";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:34:57", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:34:57', '2', 'editsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150417');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('هبة رجب عبداللة 99' , '', '', '0103345500', '0', '', '0', '2024-12-20 16:35:03', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10774', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10774','0','0','0','إضافة عميل جديد','10774', '0', '2024-12-20 16:35:03', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('هبة رجب عبداللة 99', 'هبة رجب عبداللة 99', 'هبة رجب عبداللة 99', 'هبة رجب عبداللة 99', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-20 16:35:03');
UPDATE client SET clientname = 'هبة رجب عبداللة 99', clientaddress = '', clientphone = '', clientmobile = '0103345500', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '75'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12618',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10774';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:05:24";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:35:24", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:35:24', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765805433e2f', '2024-12-20 16:33:56', '186', '28475.00', '45600', '0', '0', '17125',  '17125', '0', '17125', '1', '2024-12-20 16:35:24', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1641', '14174', '14', '16346', '20', '325', '6500', '0', '', '2024-12-20 16:35:24', '16346','','','0','0','0','0','0',null,'325','6500','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:33:56', 1, 16346, 0, 0
                    , 325, 20, 0, 0, 77, '2024-12-20 16:35:24')
                ON DUPLICATE KEY UPDATE buyprice = 325,
                        buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:35:24' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16346', '325', '20', '0', 'buyBillController.php', '32797', '', '0', '0');
UPDATE product SET  productBuyPrice = "325" WHERE productId = 16346 ;
UPDATE buybilldetail SET  quantitybefore = 18 WHERE buybilldetailid = 32797 ;
UPDATE product SET productName = 'H1641', productDescription = '', productCatId = '14', productBuyPrice = '325.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2024-12-09', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1641',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '325',lastbuyprice_withDiscount = '325',meanbuyprice = '325',meanbuyprice_withDiscount = '325' , productbuypricereal = '325.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='325',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='325',meanbuyprice_withTax='325',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='325'  WHERE productId = '16346';
UPDATE buybilldetail SET  lastbuyprice = 325 , meanbuyprice = 325, lastbuyprice_withDiscount = 325, meanbuyprice_withDiscount = 325
        , lastbuyprice_withTax = 325, meanbuyprice_withTax = 325, lastbuyprice_withDiscountAndTax = 325
                where buybilldetailid = 32797;
UPDATE productunit SET proUnitBuyPrice  = 325 * productnumber WHERE productid = 16346;
UPDATE storedetail SET  productquantity = '38', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16345';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16346', '1', '20', '0', '14174', 'اضافة فاتورة مشتريات', 'buyBillController.php', '18', '38', '77', '2024-12-20 16:33:56','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1640', '14174', '14', '16340', '25', '425', '10625', '0', '', '2024-12-20 16:35:24', '16340','','','0','0','0','0','0',null,'425','10625','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:33:56', 1, 16340, 0, 0
                    , 425, 25, 0, 0, 77, '2024-12-20 16:35:24')
                ON DUPLICATE KEY UPDATE buyprice = 425,
                        buyQuantity =buyQuantity+25, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:35:24' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16340', '425', '25', '0', 'buyBillController.php', '32798', '', '0', '0');
UPDATE product SET  productBuyPrice = "425" WHERE productId = 16340 ;
UPDATE buybilldetail SET  quantitybefore = 6 WHERE buybilldetailid = 32798 ;
UPDATE product SET productName = 'H1640', productDescription = '', productCatId = '14', productBuyPrice = '425.00', productSellAllPrice = '550.00', productSellUnitPrice = '550.00', productSellHalfPrice = '550.00', productDate = '2024-12-07', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1640',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '425',lastbuyprice_withDiscount = '425',meanbuyprice = '425',meanbuyprice_withDiscount = '425' , productbuypricereal = '425.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='425',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='425',meanbuyprice_withTax='384',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='425'  WHERE productId = '16340';
UPDATE buybilldetail SET  lastbuyprice = 425 , meanbuyprice = 425, lastbuyprice_withDiscount = 425, meanbuyprice_withDiscount = 425
        , lastbuyprice_withTax = 425, meanbuyprice_withTax = 384, lastbuyprice_withDiscountAndTax = 425
                where buybilldetailid = 32798;
UPDATE productunit SET proUnitBuyPrice  = 425 * productnumber WHERE productid = 16340;
UPDATE storedetail SET  productquantity = '31', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16340', '1', '25', '0', '14174', 'اضافة فاتورة مشتريات', 'buyBillController.php', '6', '31', '77', '2024-12-20 16:33:56','0','0');
UPDATE supplier SET  suppliercurrentDebt = '45600',suppliercurrentDebtInCurrency= '45600' , userid = '77', supplierdate = '2024-12-20 16:35:24'   WHERE supplierid = '186';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('186', '28475.00', '17125', '0', 'اضافة فاتورة مشتريات', '14174', '45600', '2024-12-20 16:33:56', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','17125','1','28475','17125','45600','0');
update buybill set dailyentryid='0,' where buybillid=14174;
COMMIT;
UPDATE product SET overAllAveragePrice = 425 WHERE productId = 16340;UPDATE product SET overAllAveragePrice = 325 WHERE productId = 16346;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:05:24";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:35:24", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:35:24', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14174');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:06:06";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:36:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:36:06', '2', 'update', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 150417 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 150417 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150417;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 16:36:06', userid = '75',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '150417';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 35893;
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 252.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 252.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 254, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 549557;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16290, '2024-12-20', 580, 500, 500
                    , 504, 500, 504, 513.34
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 500, 508, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-580, sellCostBuyPrice =sellCostBuyPrice-500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-504
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-504
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-513.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-508
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-2
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 580, 500, 500
                    , 504, 500, 504, 513.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 508, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-580, sellCostBuyPrice =sellCostBuyPrice-500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-504
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-504
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-513.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-508
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '37', userid = '2', storedetaildate = '2024-12-20 16:36:06' WHERE storedetailid = '16289';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16290', '1', '2', '0', '150417', 'تعديل فاتورة مبيعات', 'sellbillController.php', '35', '37', '2', '2024-12-20 15:54:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36368;
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        , lastbuyprice_withTax = 150, meanbuyprice_withTax = 150, lastbuyprice_withDiscountAndTax = 150
                where sellbilldetailid = 549558;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16435, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-200, sellCostBuyPrice =sellCostBuyPrice-150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-150, sellCostMeanBuyPrice = sellCostMeanBuyPrice-150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-150
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-200, sellCostBuyPrice =sellCostBuyPrice-150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-150, sellCostMeanBuyPrice = sellCostMeanBuyPrice-150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-150
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '11', userid = '2', storedetaildate = '2024-12-20 16:36:06' WHERE storedetailid = '16434';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16435', '1', '1', '0', '150417', 'تعديل فاتورة مبيعات', 'sellbillController.php', '10', '11', '2', '2024-12-20 15:54:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 34820;
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549559;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15818, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-360, sellCostMeanBuyPrice = sellCostMeanBuyPrice-360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-360
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-360, sellCostMeanBuyPrice = sellCostMeanBuyPrice-360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-360
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '10', userid = '2', storedetaildate = '2024-12-20 16:36:06' WHERE storedetailid = '15817';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15818', '1', '1', '0', '150417', 'تعديل فاتورة مبيعات', 'sellbillController.php', '9', '10', '2', '2024-12-20 15:54:11','0','0');
CALL clientInUse(10771,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '2' WHERE clientid = '10771';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10771','1232.00','1232.00','1','تعديل فاتورة مبيعات','150417', '0', '2024-12-20 15:54:11', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '1232', '0', null, '0', null, null,'', '0','1','1','1232','1','2024-12-20 15:54:11','0','0');
UPDATE client SET  inUse = 0 where clientid = 10771;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1232, 1010, 1010
                    , 1014, 1010, 1014, 1023.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1010, 1018, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1232, sellCostBuyPrice =sellCostBuyPrice-1010
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1010, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1014
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1010, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1014
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1023.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1010
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1018
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10771, '2024-12-20', 1232, 1010, 1010
                    , 1014, 1010, 1014, 1023.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1010, 1018, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1232, sellCostBuyPrice =sellCostBuyPrice-1010
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1010, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1014
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1010, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1014
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1023.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1010
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1018
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1232, 1010, 1010
                    , 1014, 1010, 1014, 1023.34, 1010, 1018)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-1232, netSellCostBuyPrice = netSellCostBuyPrice-1010
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-1010
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-1014
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-1010
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-1014
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-1023.34
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-1010
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-1018;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 150417 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 150417 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(10771,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:54:11', '06765770383691', '10771', '0.00', '1419', '0', '1', '1419', '1419', '0', '1419', '1', '2024-12-20 15:54:11', '', '2', '0', 'عروب الزقازيق 52', '2', '1', '3', '98', 'عروب الزقازيق 52', '7', '150417', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1419', userid = '2' WHERE clientid = '10771';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10771','0.00','1419','0','اضافة فاتورة مبيعات (معدله)','150430', '1419', '2024-12-20 16:36:06', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '1419', '0', null, '0', null, null,'', '0','1','1','1232','1','2024-12-20 15:54:11','0','0');
UPDATE client SET  inUse = 0 where clientid = 10771;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35893;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('270','R3325', '150430', '1', '16290', '2', '290', '580', '0', '', '1', '2024-12-20 16:36:06', '16290', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35893-2,','1','1','0','0','290','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 252.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 252.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 254, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 549610;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16290, '2024-12-20', 580, 500, 500
                    , 504, 500, 504, 513.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 500, 508, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+504
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+504
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+513.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+508
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 580, 500, 500
                    , 504, 500, 504, 513.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 508, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+504
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+504
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+513.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+508
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '35', userid = '2', storedetaildate = '2024-12-20 16:36:06' WHERE storedetailid = '16289';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16290', '1', '2', '1', '150430', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '37', '35', '2', '2024-12-20 16:36:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36368;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('150','07296', '150430', '5', '16435', '1', '200', '200', '0', '', '1', '2024-12-20 16:36:06', '16435', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36368-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        , lastbuyprice_withTax = 150, meanbuyprice_withTax = 150, lastbuyprice_withDiscountAndTax = 150
                where sellbilldetailid = 549611;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16435, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '2', storedetaildate = '2024-12-20 16:36:06' WHERE storedetailid = '16434';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16435', '1', '1', '1', '150430', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '11', '10', '2', '2024-12-20 16:36:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34820;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('360','R3275', '150430', '1', '15818', '1', '420', '420', '0', '', '1', '2024-12-20 16:36:06', '15818', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34820-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549612;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15818, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '2', storedetaildate = '2024-12-20 16:36:06' WHERE storedetailid = '15817';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15818', '1', '1', '1', '150430', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '10', '9', '2', '2024-12-20 16:36:06','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150430', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 16:36:06', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150430', '17', '10291', '1', '14', '14', '0', '', '1', '2024-12-20 16:36:06', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','14','14','0','','0','0.00','0','0','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36567;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('135','R3348', '150430', '1', '16523', '1', '185', '185', '0', '', '1', '2024-12-20 16:36:06', '16523', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36567-1,','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 135.00 , meanbuyprice = 135.00, lastbuyprice_withDiscount = 135.00, meanbuyprice_withDiscount = 135.00
        , lastbuyprice_withTax = 135, meanbuyprice_withTax = 135, lastbuyprice_withDiscountAndTax = 135
                where sellbilldetailid = 549615;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16523, '2024-12-20', 185, 135, 135
                    , 135, 135, 135, 135
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 135, 135, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+135, sellCostMeanBuyPrice = sellCostMeanBuyPrice+135
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+135
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+135
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+135
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+135
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 185, 135, 135
                    , 135, 135, 135, 135
                    , 0, 0, 0, 0
                    , 0, 0, 0, 135, 135, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+135, sellCostMeanBuyPrice = sellCostMeanBuyPrice+135
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+135
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+135
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+135
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+135
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '2', storedetaildate = '2024-12-20 16:36:06' WHERE storedetailid = '16522';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16523', '1', '1', '1', '150430', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '10', '9', '2', '2024-12-20 16:36:06','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1419, 1145, 1145
                    , 1149, 1145, 1149, 1158.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1145, 1153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1419, sellCostBuyPrice =sellCostBuyPrice+1145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1149
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1149
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1158.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10771, '2024-12-20', 1419, 1145, 1145
                    , 1149, 1145, 1149, 1158.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1145, 1153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1419, sellCostBuyPrice =sellCostBuyPrice+1145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1149
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1149
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1158.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1419, 1145, 1145
                    , 1149, 1145, 1149, 1158.34, 1145, 1153)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1419, netSellCostBuyPrice = netSellCostBuyPrice+1145
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1145
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1149
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1145
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1149
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1158.34
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1145
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1153;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150417 and newid=150430 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:06:07";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:36:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:36:07', '2', 'editprint', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150430');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:06:12";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:36:12", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 16:36:12', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:07:19";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:37:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 16:37:19', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:07:40";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:37:40", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 16:37:40', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:07:47";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 16:37:47", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:37:47', '101', 'update', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 150409 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 150409 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150409;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 16:37:48', userid = '75',delbyuserid = '101', conditions = '1'  WHERE sellbillid = '150409';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 25712;
UPDATE sellbilldetail SET  lastbuyprice = 490.00 , meanbuyprice = 490.00, lastbuyprice_withDiscount = 490.00, meanbuyprice_withDiscount = 490.00
        
                where sellbilldetailid = 549528;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11665, '2024-12-20', 510, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-510, sellCostBuyPrice =sellCostBuyPrice-490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-490, sellCostMeanBuyPrice = sellCostMeanBuyPrice-490
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-490, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-490
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-490
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 510, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-510, sellCostBuyPrice =sellCostBuyPrice-490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-490, sellCostMeanBuyPrice = sellCostMeanBuyPrice-490
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-490, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-490
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-490
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '11664';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11665', '1', '1', '0', '150409', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '101', '2024-12-20 15:44:31','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 345.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 345.00
        
                where sellbilldetailid = 549529;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13128, '2024-12-20', 180, 230, 230
                    , 345, 230, 345, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-180, sellCostBuyPrice =sellCostBuyPrice-230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-230, sellCostMeanBuyPrice = sellCostMeanBuyPrice-345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 180, 230, 230
                    , 345, 230, 345, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-180, sellCostBuyPrice =sellCostBuyPrice-230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-230, sellCostMeanBuyPrice = sellCostMeanBuyPrice-345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '3', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '13127';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13128', '1', '1', '0', '150409', 'تعديل فاتورة مبيعات', 'sellbillController.php', '2', '3', '101', '2024-12-20 15:44:31','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 150, lastbuyprice_withDiscountAndTax = 160
                where sellbilldetailid = 549530;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15324, '2024-12-20', 155, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 160, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-155, sellCostBuyPrice =sellCostBuyPrice-160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-160, sellCostMeanBuyPrice = sellCostMeanBuyPrice-160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-150
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 160, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-155, sellCostBuyPrice =sellCostBuyPrice-160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-160, sellCostMeanBuyPrice = sellCostMeanBuyPrice-160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-150
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '0', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '15323';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15324', '1', '1', '0', '150409', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-1', '0', '101', '2024-12-20 15:44:31','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        
                where sellbilldetailid = 549531;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13503, '2024-12-20', 185, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-185, sellCostBuyPrice =sellCostBuyPrice-350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-350, sellCostMeanBuyPrice = sellCostMeanBuyPrice-350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 185, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-185, sellCostBuyPrice =sellCostBuyPrice-350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-350, sellCostMeanBuyPrice = sellCostMeanBuyPrice-350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-4', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '13502';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13503', '1', '1', '0', '150409', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-5', '-4', '101', '2024-12-20 15:44:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 32680;
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 549532;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14587, '2024-12-20', 255, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-255, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 255, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-255, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '14586';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14587', '1', '1', '0', '150409', 'تعديل فاتورة مبيعات', 'sellbillController.php', '1', '2', '101', '2024-12-20 15:44:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 31746;
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 249.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 249.00
        
                where sellbilldetailid = 549533;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14267, '2024-12-20', 225, 245, 240
                    , 249, 240, 249, 248.57
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-225, sellCostBuyPrice =sellCostBuyPrice-245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-240, sellCostMeanBuyPrice = sellCostMeanBuyPrice-249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-248.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 225, 245, 240
                    , 249, 240, 249, 248.57
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-225, sellCostBuyPrice =sellCostBuyPrice-245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-240, sellCostMeanBuyPrice = sellCostMeanBuyPrice-249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-248.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '14266';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14267', '1', '1', '0', '150409', 'تعديل فاتورة مبيعات', 'sellbillController.php', '1', '2', '101', '2024-12-20 15:44:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 31865;
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 549534;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14311, '2024-12-20', 225, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-225, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 225, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-225, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '14310';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14311', '1', '1', '0', '150409', 'تعديل فاتورة مبيعات', 'sellbillController.php', '3', '4', '101', '2024-12-20 15:44:31','0','0');
CALL clientInUse(2299,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '101' WHERE clientid = '2299';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2299','1773.00','1773.00','1','تعديل فاتورة مبيعات','150409', '0', '2024-12-20 15:44:31', '101', 'sellbillController.php', 'تعديل فاتورة مبيعات', '1773', '0', null, '0', null, null,'', '0','1','1','1773','1','2024-12-20 15:44:31','0','0');
UPDATE client SET  inUse = 0 where clientid = 2299;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1773, 1975, 1970
                    , 2094, 1970, 2094, 1978.57
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,160, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1773, sellCostBuyPrice =sellCostBuyPrice-1975
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1970, sellCostMeanBuyPrice = sellCostMeanBuyPrice-2094
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1970, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-2094
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1978.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-150
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2299, '2024-12-20', 1773, 1975, 1970
                    , 2094, 1970, 2094, 1978.57
                    , 0, 0, 0, 0
                    , 0, 0, 0, 160, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1773, sellCostBuyPrice =sellCostBuyPrice-1975
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1970, sellCostMeanBuyPrice = sellCostMeanBuyPrice-2094
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1970, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-2094
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1978.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-150
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1773, 1975, 1970
                    , 2094, 1970, 2094, 1978.57, 160, 150)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-1773, netSellCostBuyPrice = netSellCostBuyPrice-1975
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-1970
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-2094
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-1970
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-2094
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-1978.57
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-160
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-150;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 150409 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 150409 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(2299,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 15:44:31', '0676574bf3a258', '2299', '0.00', '1379', '0', '1', '1379', '1379', '0', '1379', '1', '2024-12-20 15:44:31', '', '101', '0', 'ريم عبد المنعم 14', '2', '1', '3', '83', 'ريم عبد المنعم 14', '9', '150409', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1379', userid = '101' WHERE clientid = '2299';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2299','0.00','1379','0','اضافة فاتورة مبيعات (معدله)','150431', '1379', '2024-12-20 16:37:48', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '1379', '0', null, '0', null, null,'', '0','1','1','1773','1','2024-12-20 15:44:31','0','0');
UPDATE client SET  inUse = 0 where clientid = 2299;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 25712;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('490','05345', '150431', '5', '11665', '1', '280', '280', '0', '', '1', '2024-12-20 16:37:48', '11665', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','25712-1,','1','1','0','0','280','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 490.00 , meanbuyprice = 490.00, lastbuyprice_withDiscount = 490.00, meanbuyprice_withDiscount = 490.00
        
                where sellbilldetailid = 549616;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11665, '2024-12-20', 280, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+490, sellCostMeanBuyPrice = sellCostMeanBuyPrice+490
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+490, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+490
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+490
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 280, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+490, sellCostMeanBuyPrice = sellCostMeanBuyPrice+490
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+490, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+490
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+490
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '11664';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11665', '1', '1', '1', '150431', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '1', '0', '101', '2024-12-20 16:37:48','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('230','R2682', '150431', '1', '13128', '1', '155', '155', '0', '', '1', '2024-12-20 16:37:48', '13128', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 345.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 345.00
        
                where sellbilldetailid = 549617;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13128, '2024-12-20', 155, 230, 230
                    , 345, 230, 345, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 230, 230
                    , 345, 230, 345, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '13127';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13128', '1', '1', '1', '150431', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '3', '2', '101', '2024-12-20 16:37:48','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('160','06759', '150431', '5', '15324', '1', '120', '120', '0', '', '1', '2024-12-20 16:37:48', '15324', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','120','120','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 150, lastbuyprice_withDiscountAndTax = 160
                where sellbilldetailid = 549618;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15324, '2024-12-20', 120, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 160, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 120, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 160, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '15323';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15324', '1', '1', '1', '150431', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '0', '-1', '101', '2024-12-20 16:37:48','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','06036', '150431', '5', '13503', '1', '185', '185', '0', '', '1', '2024-12-20 16:37:48', '13503', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        
                where sellbilldetailid = 549619;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13503, '2024-12-20', 185, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 185, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-5', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '13502';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13503', '1', '1', '1', '150431', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '-4', '-5', '101', '2024-12-20 16:37:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32680;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','R2981', '150431', '1', '14587', '1', '230', '230', '0', '', '1', '2024-12-20 16:37:48', '14587', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32680-1,','1','1','0','0','230','230','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 549620;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14587, '2024-12-20', 230, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 230, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '14586';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14587', '1', '1', '1', '150431', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '2', '1', '101', '2024-12-20 16:37:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31746;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','R2864', '150431', '1', '14267', '1', '200', '200', '0', '', '1', '2024-12-20 16:37:48', '14267', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31746-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 249.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 249.00
        
                where sellbilldetailid = 549621;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14267, '2024-12-20', 200, 245, 240
                    , 249, 240, 249, 248.57
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+248.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 245, 240
                    , 249, 240, 249, 248.57
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+248.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '14266';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14267', '1', '1', '1', '150431', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '2', '1', '101', '2024-12-20 16:37:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31865;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','R2875', '150431', '1', '14311', '1', '175', '175', '0', '', '1', '2024-12-20 16:37:48', '14311', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31865-1,','1','1','0','0','175','175','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 549622;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14311, '2024-12-20', 175, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+175, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 175, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+175, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '101', storedetaildate = '2024-12-20 16:37:48' WHERE storedetailid = '14310';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14311', '1', '1', '1', '150431', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '4', '3', '101', '2024-12-20 16:37:48','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150431', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 16:37:48', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150431', '17', '10291', '1', '14', '14', '0', '', '1', '2024-12-20 16:37:48', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','14','14','0','','0','0.00','0','0','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1379, 1975, 1970
                    , 2094, 1970, 2094, 1978.57
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,160, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1379, sellCostBuyPrice =sellCostBuyPrice+1975
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1970, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2094
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1970, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2094
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1978.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2299, '2024-12-20', 1379, 1975, 1970
                    , 2094, 1970, 2094, 1978.57
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,160, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1379, sellCostBuyPrice =sellCostBuyPrice+1975
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1970, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2094
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1970, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2094
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1978.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1379, 1975, 1970
                    , 2094, 1970, 2094, 1978.57, 160, 150)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1379, netSellCostBuyPrice = netSellCostBuyPrice+1975
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1970
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2094
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1970
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2094
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1978.57
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+160
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+150;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150409 and newid=150431 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:07:49";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 16:37:49", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:37:49', '101', 'editprint', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150431');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:08:12";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 16:38:12", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 16:38:12', '101', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:08:34";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 16:38:34", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 16:38:34', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:08:38";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 16:38:38", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:38:38', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150430');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:09:16";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:39:16", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 16:39:16', '77', 'details', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=details&id=1757');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:09:57";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:39:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:39:57', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657fc51295e
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10626,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:31:33', '067657fc51295e', '10626', '0.00', '1202', '0', '1', '1252.00', '1252', '50', '1202', '1', '2024-12-20 16:39:57', '', '104', '0', 'هند محمد فريد', '1', '1', '3', '74', 'هند محمد فريد', '3' ,'0','','','','','-1','0','0','0','0','0','1252','0','','0','0','50','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1202', userid = '104' WHERE clientid = '10626';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10626','0.00','1202','0','اضافة فاتورة مبيعات','150432', '1202', '2024-12-20 16:39:57', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1252', '0', null, '0', null, null,'', '0','1','1','1202','1','2024-12-20 16:31:33','0','0');
UPDATE client SET  inUse = 0 where clientid = 10626;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36096;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('550','R3205', '150432', '1', '15411', '2', '620', '1240', '0', '', '1', '2024-12-20 16:39:57', '15411', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36096-2,','1','1','0','0','620','1240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 550.00 , meanbuyprice = 548.00, lastbuyprice_withDiscount = 550.00, meanbuyprice_withDiscount = 548.00
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 471, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 549625;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15411, '2024-12-20', 1240, 1100, 1100
                    , 1096, 1100, 1096, 1004.7
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 1100, 942, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1240, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1096
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1096
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1004.7
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1100
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+942
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1240, 1100, 1100
                    , 1096, 1100, 1096, 1004.7
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1100, 942, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1240, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1096
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1096
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1004.7
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1100
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+942
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '81', userid = '104', storedetaildate = '2024-12-20 16:39:57' WHERE storedetailid = '15410';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15411', '1', '2', '1', '150432', 'اضافة فاتورة مبيعات', 'sellbillController.php', '83', '81', '104', '2024-12-20 16:39:57','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150432', '17', '10291', '1', '12', '12', '0', '', '1', '2024-12-20 16:39:57', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','12','12','0','','0','0.00','0','0','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '30455',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('30405','50', '0', '1', 'اضافة فاتورة مبيعات', '150432', '30455', '2024-12-20 16:39:57', '104',  'sellbillController.php','10626','','0');
UPDATE client SET  delegateid = 74 where clientid = 10626;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1252, 1100, 1100
                    , 1096, 1100, 1096, 1004.7
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1100, 942, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1252, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1096
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1096
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1004.7
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1100
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+942
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10626, '2024-12-20', 1252, 1100, 1100
                    , 1096, 1100, 1096, 1004.7
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1100, 942, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1252, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1096
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1096
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1004.7
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1100
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+942
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1252, 1100, 1100
                    , 1096, 1100, 1096, 1004.7, 1100, 942)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1252, netSellCostBuyPrice = netSellCostBuyPrice+1100
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1100
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1096
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1100
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1096
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1004.7
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1100
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+942;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657fc51295e and sellbillId = 150432 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:09:58";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:39:58", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:39:58', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:10:03";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:40:03", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('suppliersAndProductsReportController.php', '2024-12-20 16:40:03', '77', 'all', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/suppliersAndProductsReportController.php?do=all');
UPDATE user SET loginip = "" WHERE userid = 101;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:10:15";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 16:40:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 16:40:15', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:10:15";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:10:16";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 16:40:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 16:40:16', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:10:17";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:10:21";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 16:40:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 16:40:21', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:10:26";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:40:26", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('suppliersAndProductsReportController.php', '2024-12-20 16:40:26', '77', 'all', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/suppliersAndProductsReportController.php?do=all');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:10:29";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 16:40:29", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 16:40:29', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:10:38";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 16:40:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 16:40:38', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:13:13";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:43:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:43:13', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676581beb61d5
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:39:58', '0676581beb61d5', '1', '0.00', '0', '0', '1', '1395.00', '1395', '1395', '0', '1', '2024-12-20 16:43:13', '', '104', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '5' ,'0','','','','','-1','0','0','0','0','0','1395','0','','0','0','1395','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150433', '0', '2024-12-20 16:43:13', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1395', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:39:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36115;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('280','07195', '150433', '5', '16275', '2', '330', '660', '0', '', '1', '2024-12-20 16:43:13', '16275', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36115-2,','1','1','0','0','330','660','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 281.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 281.00
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 281, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 549627;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16275, '2024-12-20', 660, 560, 560
                    , 562, 560, 562, 560
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 560, 562, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+660, sellCostBuyPrice =sellCostBuyPrice+560
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+560, sellCostMeanBuyPrice = sellCostMeanBuyPrice+562
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+560, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+562
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+560
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+560
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+562
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 660, 560, 560
                    , 562, 560, 562, 560
                    , 0, 0, 0, 0
                    , 0, 0, 0, 560, 562, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+660, sellCostBuyPrice =sellCostBuyPrice+560
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+560, sellCostMeanBuyPrice = sellCostMeanBuyPrice+562
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+560, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+562
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+560
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+560
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+562
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '38', userid = '104', storedetaildate = '2024-12-20 16:43:13' WHERE storedetailid = '16274';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16275', '1', '2', '1', '150433', 'اضافة فاتورة مبيعات', 'sellbillController.php', '40', '38', '104', '2024-12-20 16:43:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35726;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('165','07063', '150433', '5', '16074', '1', '210', '210', '0', '', '1', '2024-12-20 16:43:13', '16074', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35726-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549628;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16074, '2024-12-20', 210, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '104', storedetaildate = '2024-12-20 16:43:13' WHERE storedetailid = '16073';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16074', '1', '1', '1', '150433', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-20 16:43:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31562;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('190','R2848', '150433', '1', '14182', '1', '125', '125', '0', '', '1', '2024-12-20 16:43:13', '14182', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31562-1,','1','1','0','0','125','125','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        
                where sellbilldetailid = 549629;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14182, '2024-12-20', 125, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 125, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '104', storedetaildate = '2024-12-20 16:43:13' WHERE storedetailid = '14181';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14182', '1', '1', '1', '150433', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-20 16:43:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36113;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('355','06833', '150433', '5', '15539', '1', '400', '400', '0', '', '1', '2024-12-20 16:43:13', '15539', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36113-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 345.00 , meanbuyprice = 351.00, lastbuyprice_withDiscount = 345.00, meanbuyprice_withDiscount = 351.00
        , lastbuyprice_withTax = 345, meanbuyprice_withTax = 358, lastbuyprice_withDiscountAndTax = 345
                where sellbilldetailid = 549630;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15539, '2024-12-20', 400, 345, 345
                    , 351, 345, 351, 351.25
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 345, 358, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+351
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+351
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+351.25
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+345
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+358
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 345, 345
                    , 351, 345, 351, 351.25
                    , 0, 0, 0, 0
                    , 0, 0, 0, 345, 358, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+351
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+351
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+351.25
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+345
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+358
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '23', userid = '104', storedetaildate = '2024-12-20 16:43:13' WHERE storedetailid = '15538';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15539', '1', '1', '1', '150433', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '104', '2024-12-20 16:43:13','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '31850',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('30455','1395', '0', '1', 'اضافة فاتورة مبيعات', '150433', '31850', '2024-12-20 16:43:13', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1395, 1260, 1260
                    , 1268, 1260, 1268, 1266.25
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1070, 1085, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1395, sellCostBuyPrice =sellCostBuyPrice+1260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1268
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1268
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1266.25
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1070
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1085
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1395, 1260, 1260
                    , 1268, 1260, 1268, 1266.25
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1070, 1085, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1395, sellCostBuyPrice =sellCostBuyPrice+1260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1268
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1268
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1266.25
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1070
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1085
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1395, 1260, 1260
                    , 1268, 1260, 1268, 1266.25, 1070, 1085)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1395, netSellCostBuyPrice = netSellCostBuyPrice+1260
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1260
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1268
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1260
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1268
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1266.25
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1070
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1085;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676581beb61d5 and sellbillId = 150433 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:13:14";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:43:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:43:14', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:13:39";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:43:39", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:43:39', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067657fc0e9aff
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10774,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:31:28', '067657fc0e9aff', '10774', '0.00', '1338', '0', '1', '1338.00', '1338', '0', '1338', '1', '2024-12-20 16:43:40', '', '75', '0', 'هبة رجب عبداللة 99', '2', '1', '3', '85', 'هبة رجب عبداللة 99', '9' ,'0','','','','','-1','0','0','0','0','0','1338','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1338', userid = '75' WHERE clientid = '10774';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10774','0.00','1338','0','اضافة فاتورة مبيعات','150434', '1338', '2024-12-20 16:43:40', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1338', '0', null, '0', null, null,'', '0','1','1','1338','1','2024-12-20 16:31:28','0','0');
UPDATE client SET  inUse = 0 where clientid = 10774;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36048;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07001', '150434', '5', '15970', '1', '200', '200', '0', '', '1', '2024-12-20 16:43:40', '15970', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36048-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 142, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549631;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15970, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140.45
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 142, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140.45
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+142
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140.45
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 142, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140.45
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+142
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '17', userid = '75', storedetaildate = '2024-12-20 16:43:40' WHERE storedetailid = '15969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15970', '1', '1', '1', '150434', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '75', '2024-12-20 16:43:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','R2960', '150434', '1', '14551', '1', '185', '185', '0', '', '1', '2024-12-20 16:43:40', '14551', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 224.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 224.00
        
                where sellbilldetailid = 549632;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14551, '2024-12-20', 185, 200, 200
                    , 224, 200, 224, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+224
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+224
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 185, 200, 200
                    , 224, 200, 224, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+224
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+224
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-5', userid = '75', storedetaildate = '2024-12-20 16:43:40' WHERE storedetailid = '14550';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14551', '1', '1', '1', '150434', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-4', '-5', '75', '2024-12-20 16:43:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('135','05161', '150434', '5', '11180', '1', '150', '150', '0', '', '1', '2024-12-20 16:43:40', '11180', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','150','150','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 133.00 , meanbuyprice = 92.00, lastbuyprice_withDiscount = 135.00, meanbuyprice_withDiscount = 92.00
        , lastbuyprice_withTax = 133, meanbuyprice_withTax = 84
                where sellbilldetailid = 549633;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11180, '2024-12-20', 150, 135, 133
                    , 92, 135, 92, 133.31
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 133, 84, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+133, sellCostMeanBuyPrice = sellCostMeanBuyPrice+92
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+92
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+133.31
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+133
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+84
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 150, 135, 133
                    , 92, 135, 92, 133.31
                    , 0, 0, 0, 0
                    , 0, 0, 0, 133, 84, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+133, sellCostMeanBuyPrice = sellCostMeanBuyPrice+92
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+92
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+133.31
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+133
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+84
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-6', userid = '75', storedetaildate = '2024-12-20 16:43:40' WHERE storedetailid = '11179';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11180', '1', '1', '1', '150434', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-5', '-6', '75', '2024-12-20 16:43:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','R2942', '150434', '1', '14450', '1', '220', '220', '0', '', '1', '2024-12-20 16:43:40', '14450', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 549634;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14450, '2024-12-20', 220, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 16:43:40' WHERE storedetailid = '14449';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14450', '1', '1', '1', '150434', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 16:43:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('210','R3005', '150434', '1', '10120', '1', '150', '150', '0', '', '1', '2024-12-20 16:43:40', '10120', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','150','150','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 225.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 225.00
        
                where sellbilldetailid = 549635;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10120, '2024-12-20', 150, 210, 170
                    , 225, 170, 225, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+225
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+225
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 150, 210, 170
                    , 225, 170, 225, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+225
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+225
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '75', storedetaildate = '2024-12-20 16:43:40' WHERE storedetailid = '10119';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10120', '1', '1', '1', '150434', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-20 16:43:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','عرض 200', '150434', '18', '10353', '2', '200', '400', '0', '', '1', '2024-12-20 16:43:40', '10353', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        
                where sellbilldetailid = 549636;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10353, '2024-12-20', 400, 400, 400
                    , 400, 400, 400, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 400, 400
                    , 400, 400, 400, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-28', userid = '75', storedetaildate = '2024-12-20 16:43:40' WHERE storedetailid = '10352';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10353', '1', '2', '1', '150434', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-26', '-28', '75', '2024-12-20 16:43:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150434', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 16:43:40', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150434', '17', '10291', '1', '13', '13', '0', '', '1', '2024-12-20 16:43:40', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','13','13','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 85 where clientid = 10774;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1338, 1335, 1293
                    , 1331, 1295, 1331, 913.76
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,273, 226, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1338, sellCostBuyPrice =sellCostBuyPrice+1335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1293, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1331
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1331
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+913.76
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+273
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10774, '2024-12-20', 1338, 1335, 1293
                    , 1331, 1295, 1331, 913.76
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,273, 226, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1338, sellCostBuyPrice =sellCostBuyPrice+1335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1293, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1331
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1331
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+913.76
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+273
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1338, 1335, 1293
                    , 1331, 1295, 1331, 913.76, 273, 226)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1338, netSellCostBuyPrice = netSellCostBuyPrice+1335
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1293
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1331
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1295
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1331
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+913.76
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+273
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+226;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067657fc0e9aff and sellbillId = 150434 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:13:41";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:43:41", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:43:41', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:14:42";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:44:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:44:42', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:15:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:45:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:45:27', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676582db1bcfe
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 16:44:43', '0676582db1bcfe', '1', '0.00', '0', '0', '1', '470', '470', '-470', '0', '1', '2024-12-20 16:45:27', '', '104', '0', 'نقدي','1', '0', '5', '4', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-470','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16853', '0', '2024-12-20 16:45:27', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '470', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:44:43','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('390.00', 'H1423', '16853', '14', '15709', '1', '470', '470', '0', '', '1', '0', '15709', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','470','470','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 390.00 , meanbuyprice = 390.00, lastbuyprice_withDiscount = 390.00, meanbuyprice_withDiscount = 390.00
        , lastbuyprice_withTax = 390, meanbuyprice_withTax = 390, lastbuyprice_withDiscountAndTax = 390
                where returnsellbilldetailid = 22043;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15709, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 470, 390, 390, 390
                    , 390, 390, 390, 0, 1, 0, 0, 390, 390)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+470, returnSellCostBuyPrice = returnSellCostBuyPrice+390, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+390
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+390, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+390
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+390
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+390
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+390
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+390
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 470, 390, 390, 390
                    , 390, 390, 390, 0, 0, 390, 390)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+470, returnSellCostBuyPrice = returnSellCostBuyPrice+390, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+390
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+390, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+390
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+390
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+390
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+390
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+390;
UPDATE storedetail SET  productquantity = '65', userid = '104', storedetaildate = '2024-12-20 16:45:27' WHERE storedetailid = '15708';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15709', '1', '1', '0', '16853', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '64', '65', '104', '2024-12-20 16:45:27','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '31380',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('31850','-470', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16853', '31380', '2024-12-20 16:45:27', '104',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 470, 390, 390, 390
                    , 390, 390, 390 ,0, 0, 390, 390)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+470, returnSellCostBuyPrice = returnSellCostBuyPrice+390, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+390
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+390, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+390
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+390
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+390
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+390
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+390;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 470, 390, 390, 390
                    , 390, 390, 390 ,0, 0, 390, 390)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+470, returnSellCostBuyPrice = returnSellCostBuyPrice+390, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+390
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+390, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+390
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+390
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+390
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+390
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+390;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -470, -390, -390
                    , -390, -390, -390, -390, -390, -390)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-470, netSellCostBuyPrice = netSellCostBuyPrice+-390
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-390
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-390
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-390
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-390
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-390
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-390
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-390;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676582db1bcfe and sellbillId = 16853 and returnsellbillId = 16853
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:15:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:45:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:45:28', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:15:37";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:45:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:45:37', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658282a544b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:43:14', '067658282a544b', '1', '0.00', '0', '0', '1', '1390.00', '1390', '1390', '0', '1', '2024-12-20 16:45:37', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1390','0','','0','0','1390','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150435', '0', '2024-12-20 16:45:37', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1390', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:43:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36151;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','07259', '150435', '5', '16389', '1', '300', '300', '0', '', '1', '2024-12-20 16:45:37', '16389', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36151-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549639;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16389, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '104', storedetaildate = '2024-12-20 16:45:37' WHERE storedetailid = '16388';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16389', '1', '1', '1', '150435', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-20 16:45:37','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36358;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06603', '150435', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-20 16:45:38', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36358-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 226.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 226.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 227, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549640;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15038, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 225, 225
                    , 226, 225, 226, 235.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 227, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+226
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+226
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+227
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '44', userid = '104', storedetaildate = '2024-12-20 16:45:38' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '150435', 'اضافة فاتورة مبيعات', 'sellbillController.php', '45', '44', '104', '2024-12-20 16:45:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36377;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('675','H1665', '150435', '14', '16444', '1', '800', '800', '0', '', '1', '2024-12-20 16:45:38', '16444', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36377-1,','1','1','0','0','800','800','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 675.00 , meanbuyprice = 675.00, lastbuyprice_withDiscount = 675.00, meanbuyprice_withDiscount = 675.00
        , lastbuyprice_withTax = 675, meanbuyprice_withTax = 675, lastbuyprice_withDiscountAndTax = 675
                where sellbilldetailid = 549641;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16444, '2024-12-20', 800, 675, 675
                    , 675, 675, 675, 675
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 675, 675, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+675
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+675, sellCostMeanBuyPrice = sellCostMeanBuyPrice+675
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+675, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+675
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+675
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+675
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+675
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 800, 675, 675
                    , 675, 675, 675, 675
                    , 0, 0, 0, 0
                    , 0, 0, 0, 675, 675, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+675
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+675, sellCostMeanBuyPrice = sellCostMeanBuyPrice+675
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+675, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+675
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+675
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+675
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+675
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '104', storedetaildate = '2024-12-20 16:45:38' WHERE storedetailid = '16443';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16444', '1', '1', '1', '150435', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-20 16:45:38','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '32770',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('31380','1390', '0', '1', 'اضافة فاتورة مبيعات', '150435', '32770', '2024-12-20 16:45:38', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1390, 1140, 1140
                    , 1141, 1140, 1141, 1150.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1140, 1142, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1390, sellCostBuyPrice =sellCostBuyPrice+1140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1141
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1141
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1150.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1142
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1390, 1140, 1140
                    , 1141, 1140, 1141, 1150.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1140, 1142, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1390, sellCostBuyPrice =sellCostBuyPrice+1140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1141
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1141
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1150.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1142
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1390, 1140, 1140
                    , 1141, 1140, 1141, 1150.95, 1140, 1142)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1390, netSellCostBuyPrice = netSellCostBuyPrice+1140
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1140
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1141
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1140
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1141
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1150.95
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1142;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658282a544b and sellbillId = 150435 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:15:38";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:45:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:45:38', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:16:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:46:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:46:46', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658312c8768
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:45:38', '067658312c8768', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-20 16:46:46', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','300','0','','0','0','300','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150436', '0', '2024-12-20 16:46:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:45:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36359;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','07260', '150436', '5', '16374', '1', '300', '300', '0', '', '1', '2024-12-20 16:46:46', '16374', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36359-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 231.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 231.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 238, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549642;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16374, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '104', storedetaildate = '2024-12-20 16:46:46' WHERE storedetailid = '16373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16374', '1', '1', '1', '150436', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-20 16:46:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '33070',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('32770','300', '0', '1', 'اضافة فاتورة مبيعات', '150436', '33070', '2024-12-20 16:46:46', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 3 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 300, 225, 225
                    , 231, 225, 231, 237.5, 225, 238)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+225
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+225
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+231
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+225
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+231
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+237.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+225
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+238;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658312c8768 and sellbillId = 150436 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:16:47";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:46:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:46:47', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:16:53";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:46:53", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:46:53', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:17:38";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:47:38", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:47:38', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765835dc3528
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1236,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:46:53', '06765835dc3528', '1236', '4434.00', '4959', '0', '1', '525.00', '525', '0', '525', '1', '2024-12-20 16:47:38', '', '75', '0', 'ايمان محمد القناطر 14', '2', '1', '3', '98', 'ايمان محمد القناطر 14', '2' ,'0','','','','','-1','0','0','0','0','0','525','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '4959', userid = '75' WHERE clientid = '1236';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1236','4434.00','525','0','اضافة فاتورة مبيعات','150437', '4959', '2024-12-20 16:47:38', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '525', '0', null, '0', null, null,'', '0','1','1','525','1','2024-12-20 16:46:53','0','0');
UPDATE client SET  inUse = 0 where clientid = 1236;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35413;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('420','H1510', '150437', '14', '15974', '1', '520', '520', '0', '', '1', '2024-12-20 16:47:38', '15974', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35413-1,','1','1','0','0','520','520','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 549643;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15974, '2024-12-20', 520, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 520, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 16:47:38' WHERE storedetailid = '15973';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15974', '1', '1', '1', '150437', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 16:47:38','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150437', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-20 16:47:38', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','5','5','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 98 where clientid = 1236;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 525, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+525, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1236, '2024-12-20', 525, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+525, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 525, 420, 420
                    , 420, 420, 420, 420, 420, 420)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+525, netSellCostBuyPrice = netSellCostBuyPrice+420
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+420
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+420
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+420
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+420
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+420
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+420
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+420;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765835dc3528 and sellbillId = 150437 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:17:39";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:47:39", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:47:39', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:18:16";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:48:16", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:48:16', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765829d3ef60
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8149,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:43:41', '06765829d3ef60', '8149', '0.00', '2071', '0', '1', '2071.00', '2071', '0', '2071', '1', '2024-12-20 16:48:17', '', '75', '0', 'هند التركي T190', '2', '1', '3', '89', 'هند التركي T190', '10' ,'0','','','','','-1','0','0','0','0','0','2071','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2071', userid = '75' WHERE clientid = '8149';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8149','0.00','2071','0','اضافة فاتورة مبيعات','150438', '2071', '2024-12-20 16:48:17', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2071', '0', null, '0', null, null,'', '0','1','1','2071','1','2024-12-20 16:43:41','0','0');
UPDATE client SET  inUse = 0 where clientid = 8149;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('495','05400', '150438', '5', '11766', '1', '335', '335', '0', '', '1', '2024-12-20 16:48:17', '11766', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','335','335','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 495.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 492.00
        
                where sellbilldetailid = 549645;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11766, '2024-12-20', 335, 495, 495
                    , 495, 495, 492, 491.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+335, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+492
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+491.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 335, 495, 495
                    , 495, 495, 492, 491.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+335, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+492
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+491.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 16:48:17' WHERE storedetailid = '11765';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11766', '1', '1', '1', '150438', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 16:48:17','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','R2611', '150438', '1', '12770', '1', '155', '155', '0', '', '1', '2024-12-20 16:48:17', '12770', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 549646;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12770, '2024-12-20', 155, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '75', storedetaildate = '2024-12-20 16:48:17' WHERE storedetailid = '12769';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12770', '1', '1', '1', '150438', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '75', '2024-12-20 16:48:17','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('410','R3335', '150438', '1', '16410', '1', '470', '470', '0', '', '1', '2024-12-20 16:48:17', '16410', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','470','470','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
        , lastbuyprice_withTax = 410, meanbuyprice_withTax = 410, lastbuyprice_withDiscountAndTax = 410
                where sellbilldetailid = 549647;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16410, '2024-12-20', 470, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '75', storedetaildate = '2024-12-20 16:48:17' WHERE storedetailid = '16409';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16410', '1', '1', '1', '150438', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '75', '2024-12-20 16:48:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 32007;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('180','R2916', '150438', '1', '14386', '2', '175', '350', '0', '', '1', '2024-12-20 16:48:17', '14386', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32007-2,','1','1','0','0','175','350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
        , lastbuyprice_withTax = 180, meanbuyprice_withTax = 45, lastbuyprice_withDiscountAndTax = 180
                where sellbilldetailid = 549648;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14386, '2024-12-20', 350, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 360, 90, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+90
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 350, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 90, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+90
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 16:48:17' WHERE storedetailid = '14385';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14386', '1', '2', '1', '150438', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '2', '75', '2024-12-20 16:48:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36122;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('360','07263', '150438', '5', '16383', '1', '420', '420', '0', '', '1', '2024-12-20 16:48:17', '16383', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36122-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 180, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549649;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16383, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+180
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+180
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '75', storedetaildate = '2024-12-20 16:48:17' WHERE storedetailid = '16382';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16383', '1', '1', '1', '150438', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-20 16:48:17','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('100','عرض 100', '150438', '18', '10345', '1', '100', '100', '0', '', '1', '2024-12-20 16:48:17', '10345', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','100','100','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 100.00 , meanbuyprice = 100.00, lastbuyprice_withDiscount = 100.00, meanbuyprice_withDiscount = 100.00
        
                where sellbilldetailid = 549650;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10345, '2024-12-20', 100, 100, 100
                    , 100, 100, 100, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, sellCostBuyPrice =sellCostBuyPrice+100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+100
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+100
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 100, 100, 100
                    , 100, 100, 100, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, sellCostBuyPrice =sellCostBuyPrice+100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+100
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+100
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-107', userid = '75', storedetaildate = '2024-12-20 16:48:17' WHERE storedetailid = '10344';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10345', '1', '1', '1', '150438', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-106', '-107', '75', '2024-12-20 16:48:17','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','عرض 200', '150438', '18', '10353', '1', '200', '200', '0', '', '1', '2024-12-20 16:48:17', '10353', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        
                where sellbilldetailid = 549651;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10353, '2024-12-20', 200, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-29', userid = '75', storedetaildate = '2024-12-20 16:48:17' WHERE storedetailid = '10352';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10353', '1', '1', '1', '150438', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-28', '-29', '75', '2024-12-20 16:48:17','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150438', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 16:48:17', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150438', '17', '10291', '1', '21', '21', '0', '', '1', '2024-12-20 16:48:17', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','21','21','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 89 where clientid = 8149;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2071, 2175, 2175
                    , 2175, 2175, 2172, 1871.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1130, 680, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2071, sellCostBuyPrice =sellCostBuyPrice+2175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2175
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2172
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1871.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1130
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+680
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8149, '2024-12-20', 2071, 2175, 2175
                    , 2175, 2175, 2172, 1871.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1130, 680, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2071, sellCostBuyPrice =sellCostBuyPrice+2175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2175
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2172
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1871.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1130
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+680
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2071, 2175, 2175
                    , 2175, 2175, 2172, 1871.67, 1130, 680)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2071, netSellCostBuyPrice = netSellCostBuyPrice+2175
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2175
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2175
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2175
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2172
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1871.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1130
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+680;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765829d3ef60 and sellbillId = 150438 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:18:18";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:48:18", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:48:18', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:19:03";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:49:03", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:49:03', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765838b41193
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2665,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:47:39', '06765838b41193', '2665', '2.00', '345', '0', '1', '343.00', '343', '0', '343', '1', '2024-12-20 16:49:03', '', '75', '0', 'منة حمدي u730', '2', '1', '3', '91', 'منة حمدي u730', '3' ,'0','','','','','-1','0','0','0','0','0','343','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '345', userid = '75' WHERE clientid = '2665';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2665','2.00','343','0','اضافة فاتورة مبيعات','150439', '345', '2024-12-20 16:49:03', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '343', '0', null, '0', null, null,'', '0','1','1','343','1','2024-12-20 16:47:39','0','0');
UPDATE client SET  inUse = 0 where clientid = 2665;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36297;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('260','06903', '150439', '5', '15753', '1', '320', '320', '0', '', '1', '2024-12-20 16:49:03', '15753', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36297-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 260.00
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 260, lastbuyprice_withDiscountAndTax = 260
                where sellbilldetailid = 549654;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15753, '2024-12-20', 320, 260, 260
                    , 260, 260, 260, 259.44
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 260, 260, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.44
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+260
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 260, 260
                    , 260, 260, 260, 259.44
                    , 0, 0, 0, 0
                    , 0, 0, 0, 260, 260, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.44
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+260
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '75', storedetaildate = '2024-12-20 16:49:03' WHERE storedetailid = '15752';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15753', '1', '1', '1', '150439', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '75', '2024-12-20 16:49:03','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150439', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 16:49:03', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150439', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-20 16:49:03', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','3','3','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 91 where clientid = 2665;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 343, 260, 260
                    , 260, 260, 260, 259.44
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,260, 260, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+343, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.44
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+260
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2665, '2024-12-20', 343, 260, 260
                    , 260, 260, 260, 259.44
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,260, 260, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+343, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.44
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+260
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 343, 260, 260
                    , 260, 260, 260, 259.44, 260, 260)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+343, netSellCostBuyPrice = netSellCostBuyPrice+260
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+260
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+260
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+260
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+260
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+259.44
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+260
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+260;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765838b41193 and sellbillId = 150439 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:19:04";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:49:04", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:49:04', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:19:08";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:49:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:49:08', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247986
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2277,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '23' , clientdate = '2024-12-20 16:49:08', userid = '2' WHERE clientid = '2277';
UPDATE client SET  inUse = 0 where clientid = 2277;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2277','323.00','300','1','ايصال تحصيل (( قبض من عميل ))','247986', '23', '2024-12-20 16:31:10', '2', 'clientPayedDeptController.php', '   ', '300', '0', null, '0', null, null,'', '-1','1','1','300','1','','3654','0');
UPDATE save SET  savecurrentvalue = '140714.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('140414.50','300', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248002', '140714.5', '2024-12-20 16:49:08', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '300', '300', '2024-12-20', '2', '0', '0', '2024-12-20 16:49:08','اضافة ايصال سداد للعميل مروة نجاتي المنيا y15','1','0','0','0','248002','clientPayedDeptController.php?do=show&id=248002');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122317', '-1', '300', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '300', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122317', '-1', '300', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-300', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '2277', clientdebtchangebefore = '323.000', clientdebtchangeamount = '300.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247986', clientdebtchangeafter = '23.000', clientdebtchangedate = '2024-12-20 16:31:10', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '300.00',discount='', reciptid='0', dailyentryid = '122317',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='300',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248002';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247986 -clientdebtchangeId = 248002
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:19:09";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:49:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:49:09', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:19:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:49:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:49:38', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248003
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(95,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '51' , clientdate = '2024-12-20 16:49:38', userid = '2' WHERE clientid = '95';
UPDATE client SET  inUse = 0 where clientid = 95;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('95','970.00','919','1','ايصال تحصيل (( قبض من عميل ))','248003', '51', '2024-12-20 16:49:09', '2', 'clientPayedDeptController.php', '   ', '919', '0', null, '0', null, null,'', '-1','1','1','919','1','','3655','0');
UPDATE save SET  savecurrentvalue = '141633.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('140714.50','919', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248003', '141633.5', '2024-12-20 16:49:38', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '919', '919', '2024-12-20', '2', '0', '0', '2024-12-20 16:49:38','اضافة ايصال سداد للعميل سارة شلبي f218','1','0','0','0','248003','clientPayedDeptController.php?do=show&id=248003');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122318', '-1', '919', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '919', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122318', '-1', '919', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-919', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '95', clientdebtchangebefore = '970.000', clientdebtchangeamount = '919.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248003', clientdebtchangeafter = '51.000', clientdebtchangedate = '2024-12-20 16:49:09', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '919.00',discount='', reciptid='0', dailyentryid = '122318',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='919',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248003';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248003 -clientdebtchangeId = 248003
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:19:39";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:49:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:49:39', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:19:53";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:49:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:49:53', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658357904cc
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:46:47', '067658357904cc', '1', '0.00', '0', '0', '1', '610.00', '610', '610', '0', '1', '2024-12-20 16:49:53', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','610','0','','0','0','610','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150440', '0', '2024-12-20 16:49:53', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '610', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:46:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36085;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('525','R3330', '150440', '1', '16365', '1', '610', '610', '0', '', '1', '2024-12-20 16:49:53', '16365', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36085-1,','1','1','0','0','610','610','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 525.00 , meanbuyprice = 525.00, lastbuyprice_withDiscount = 525.00, meanbuyprice_withDiscount = 525.00
        , lastbuyprice_withTax = 525, meanbuyprice_withTax = 525, lastbuyprice_withDiscountAndTax = 525
                where sellbilldetailid = 549657;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16365, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '104', storedetaildate = '2024-12-20 16:49:53' WHERE storedetailid = '16364';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16365', '1', '1', '1', '150440', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-20 16:49:53','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '33680',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('33070','610', '0', '1', 'اضافة فاتورة مبيعات', '150440', '33680', '2024-12-20 16:49:53', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 97 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 610, 525, 525
                    , 525, 525, 525, 525, 525, 525)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+610, netSellCostBuyPrice = netSellCostBuyPrice+525
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+525
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+525
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+525
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+525
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+525
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+525
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+525;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658357904cc and sellbillId = 150440 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:19:54";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:49:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:49:54', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:20:04";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:50:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:50:04', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248004
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3976,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '21' , clientdate = '2024-12-20 16:50:04', userid = '2' WHERE clientid = '3976';
UPDATE client SET  inUse = 0 where clientid = 3976;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3976','1263.00','1242','1','ايصال تحصيل (( قبض من عميل ))','248004', '21', '2024-12-20 16:49:39', '2', 'clientPayedDeptController.php', '   ', '1242', '0', null, '0', null, null,'', '-1','1','1','1242','1','','3656','0');
UPDATE save SET  savecurrentvalue = '142875.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('141633.50','1242', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248005', '142875.5', '2024-12-20 16:50:04', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1242', '1242', '2024-12-20', '2', '0', '0', '2024-12-20 16:50:04','اضافة ايصال سداد للعميل رحاب السيد L195','1','0','0','0','248005','clientPayedDeptController.php?do=show&id=248005');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122319', '-1', '1242', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1242', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122319', '-1', '1242', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1242', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '3976', clientdebtchangebefore = '1263.000', clientdebtchangeamount = '1242.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248004', clientdebtchangeafter = '21.000', clientdebtchangedate = '2024-12-20 16:49:39', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1242.00',discount='', reciptid='0', dailyentryid = '122319',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1242',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248005';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248004 -clientdebtchangeId = 248005
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:20:05";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:50:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:50:05', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:20:30";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:50:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:50:30', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248006
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2713,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 16:50:30', userid = '2' WHERE clientid = '2713';
UPDATE client SET  inUse = 0 where clientid = 2713;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2713','1303.00','1303','1','ايصال تحصيل (( قبض من عميل ))','248006', '0', '2024-12-20 16:50:05', '2', 'clientPayedDeptController.php', '   ', '1303', '0', null, '0', null, null,'', '-1','1','1','1303','1','','3657','0');
UPDATE save SET  savecurrentvalue = '144178.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('142875.50','1303', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248006', '144178.5', '2024-12-20 16:50:30', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1303', '1303', '2024-12-20', '2', '0', '0', '2024-12-20 16:50:30','اضافة ايصال سداد للعميل بسنت شبانة p1','1','0','0','0','248006','clientPayedDeptController.php?do=show&id=248006');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122320', '-1', '1303', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1303', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122320', '-1', '1303', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1303', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '2713', clientdebtchangebefore = '1303.000', clientdebtchangeamount = '1303.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248006', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 16:50:05', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1303.00',discount='', reciptid='0', dailyentryid = '122320',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1303',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248006';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248006 -clientdebtchangeId = 248006
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:20:30";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:50:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:50:30', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('حسناء عبداللة 33' , '', '', '01069755297', '0', '', '0', '2024-12-20 16:50:32', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10775', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10775','0','0','0','إضافة عميل جديد','10775', '0', '2024-12-20 16:50:32', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('حسناء عبداللة 33', 'حسناء عبداللة 33', 'حسناء عبداللة 33', 'حسناء عبداللة 33', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-20 16:50:32');
UPDATE client SET clientname = 'حسناء عبداللة 33', clientaddress = '', clientphone = '', clientmobile = '01069755297', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '75'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12619',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10775';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:20:55";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:50:55", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-20 16:50:55', '77', 'showbarcode', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:20:56";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:50:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:50:56', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248007
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(763,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '1320' , clientdate = '2024-12-20 16:50:56', userid = '2' WHERE clientid = '763';
UPDATE client SET  inUse = 0 where clientid = 763;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('763','1520.00','200','1','ايصال تحصيل (( قبض من عميل ))','248007', '1320', '2024-12-20 16:50:31', '2', 'clientPayedDeptController.php', '   ', '200', '0', null, '0', null, null,'', '-1','1','1','200','1','','3658','0');
UPDATE save SET  savecurrentvalue = '144378.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('144178.50','200', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248008', '144378.5', '2024-12-20 16:50:56', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '200', '200', '2024-12-20', '2', '0', '0', '2024-12-20 16:50:56','اضافة ايصال سداد للعميل ياسمين مهدي زفتي y43','1','0','0','0','248008','clientPayedDeptController.php?do=show&id=248008');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122321', '-1', '200', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '200', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122321', '-1', '200', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-200', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '763', clientdebtchangebefore = '1520.000', clientdebtchangeamount = '200.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248007', clientdebtchangeafter = '1320.000', clientdebtchangedate = '2024-12-20 16:50:31', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '200.00',discount='', reciptid='0', dailyentryid = '122321',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='200',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248008';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248007 -clientdebtchangeId = 248008
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:20:57";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:50:57", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:50:57', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:21:15";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:51:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:51:15', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676584125aa40
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:49:54', '0676584125aa40', '1', '0.00', '0', '0', '1', '1300.00', '1300', '1300', '0', '1', '2024-12-20 16:51:16', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','1300','0','','0','0','1300','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150441', '0', '2024-12-20 16:51:16', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:49:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35969;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('550','R3327', '150441', '1', '16277', '2', '650', '1300', '0', '', '1', '2024-12-20 16:51:16', '16277', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35969-2,','1','1','0','0','650','1300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 550.00 , meanbuyprice = 549.00, lastbuyprice_withDiscount = 550.00, meanbuyprice_withDiscount = 547.00
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 548, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 549658;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16277, '2024-12-20', 1300, 1100, 1100
                    , 1098, 1100, 1094, 1093.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 1100, 1096, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1300, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1098
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1094
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1093.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1100
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1096
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1300, 1100, 1100
                    , 1098, 1100, 1094, 1093.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1100, 1096, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1300, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1098
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1094
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1093.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1100
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1096
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '40', userid = '104', storedetaildate = '2024-12-20 16:51:16' WHERE storedetailid = '16276';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16277', '1', '2', '1', '150441', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42', '40', '104', '2024-12-20 16:51:16','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '34980',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('33680','1300', '0', '1', 'اضافة فاتورة مبيعات', '150441', '34980', '2024-12-20 16:51:16', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1300, 1100, 1100
                    , 1098, 1100, 1094, 1093.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1100, 1096, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1300, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1098
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1094
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1093.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1100
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1096
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1300, 1100, 1100
                    , 1098, 1100, 1094, 1093.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1100, 1096, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1300, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1098
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1094
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1093.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1100
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1096
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1300, 1100, 1100
                    , 1098, 1100, 1094, 1093.34, 1100, 1096)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1300, netSellCostBuyPrice = netSellCostBuyPrice+1100
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1100
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1098
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1100
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1094
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1093.34
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1100
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1096;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676584125aa40 and sellbillId = 150441 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:21:16";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:51:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:51:16', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:21:16";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:51:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:51:16', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248009
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(763,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '118' , clientdate = '2024-12-20 16:51:16', userid = '2' WHERE clientid = '763';
UPDATE client SET  inUse = 0 where clientid = 763;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('763','1320.00','1202','1','ايصال تحصيل (( قبض من عميل ))','248009', '118', '2024-12-20 16:50:58', '2', 'clientPayedDeptController.php', '   ', '1202', '0', null, '0', null, null,'', '-1','1','1','1202','1','','3659','0');
UPDATE save SET  savecurrentvalue = '145580.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('144378.50','1202', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248010', '145580.5', '2024-12-20 16:51:16', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1202', '1202', '2024-12-20', '2', '0', '0', '2024-12-20 16:51:17','اضافة ايصال سداد للعميل ياسمين مهدي زفتي y43','1','0','0','0','248010','clientPayedDeptController.php?do=show&id=248010');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122322', '-1', '1202', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1202', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122322', '-1', '1202', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1202', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '763', clientdebtchangebefore = '1320.000', clientdebtchangeamount = '1202.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248009', clientdebtchangeafter = '118.000', clientdebtchangedate = '2024-12-20 16:50:58', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1202.00',discount='', reciptid='0', dailyentryid = '122322',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1202',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248010';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248009 -clientdebtchangeId = 248010
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:21:17";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:51:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:51:17', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:21:18";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:51:18", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:51:18', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:21:46";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:51:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:51:46', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248011
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10626,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 16:51:46', userid = '2' WHERE clientid = '10626';
UPDATE client SET  inUse = 0 where clientid = 10626;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10626','1202.00','1202','1','ايصال تحصيل (( قبض من عميل ))','248011', '0', '2024-12-20 16:51:17', '2', 'clientPayedDeptController.php', '   ', '1202', '0', null, '0', null, null,'', '-1','1','1','1202','1','','3660','0');
UPDATE save SET  savecurrentvalue = '146782.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('145580.50','1202', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248011', '146782.5', '2024-12-20 16:51:46', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1202', '1202', '2024-12-20', '2', '0', '0', '2024-12-20 16:51:46','اضافة ايصال سداد للعميل هند محمد فريد','1','0','0','0','248011','clientPayedDeptController.php?do=show&id=248011');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122323', '-1', '1202', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1202', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122323', '12292', '1202', '','0');
UPDATE accountstree SET name = 'هند محمد فريد', customName = 'هند محمد فريد', customNameEn = 'هند محمد فريد', nameEn = 'هند محمد فريد', parent = '58', accountNature = '0', theValue = '-9139', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '9', del = '0', sysdate = '2024-12-07 14:17:13' WHERE id = '12292';
UPDATE clientdebtchange SET clientid = '10626', clientdebtchangebefore = '1202.000', clientdebtchangeamount = '1202.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248011', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 16:51:17', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1202.00',discount='', reciptid='0', dailyentryid = '122323',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1202',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248011';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248011 -clientdebtchangeId = 248011
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:21:47";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:51:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:51:47', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7344','','5','550','620', '620','620', '2024-12-20', '0', '77', '1', '07344', '0', '0', '0', '0', '0', '550','550','550','550','550','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','550','550','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16526, 1,'2024-12-20 16:51:56',77)
                ON DUPLICATE KEY UPDATE productid = 16526, edited = 1, sysdate = '2024-12-20 16:51:56', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16526', '1', '2024-12-20', '77', '0','1652601','620','620','620','550','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16526', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16526', '1', '0', '0', '16526', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:22:15";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:52:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:52:15', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248012
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(235,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '161' , clientdate = '2024-12-20 16:52:16', userid = '2' WHERE clientid = '235';
UPDATE client SET  inUse = 0 where clientid = 235;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('235','761.00','600','1','ايصال تحصيل (( قبض من عميل ))','248012', '161', '2024-12-20 16:51:47', '2', 'clientPayedDeptController.php', '   ', '600', '0', null, '0', null, null,'', '-1','1','1','600','1','','3661','0');
UPDATE save SET  savecurrentvalue = '147382.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('146782.50','600', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248012', '147382.5', '2024-12-20 16:52:16', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '600', '600', '2024-12-20', '2', '0', '0', '2024-12-20 16:52:16','اضافة ايصال سداد للعميل لمياء حداد i71','1','0','0','0','248012','clientPayedDeptController.php?do=show&id=248012');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122324', '-1', '600', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '600', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122324', '-1', '600', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-600', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '235', clientdebtchangebefore = '761.000', clientdebtchangeamount = '600.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248012', clientdebtchangeafter = '161.000', clientdebtchangedate = '2024-12-20 16:51:47', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '600.00',discount='', reciptid='0', dailyentryid = '122324',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='600',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248012';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248012 -clientdebtchangeId = 248012
-- ----------------------------------------------------------------------------------------------------

INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7339','','5','330','380', '380','380', '2024-12-20', '0', '77', '1', '07339', '0', '0', '0', '0', '0', '330','330','330','330','330','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','330','330','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16527, 1,'2024-12-20 16:52:16',77)
                ON DUPLICATE KEY UPDATE productid = 16527, edited = 1, sysdate = '2024-12-20 16:52:16', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16527', '1', '2024-12-20', '77', '0','1652701','380','380','380','330','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16527', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16527', '1', '0', '0', '16527', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:22:16";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:52:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:52:16', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7340','','5','330','380', '380','380', '2024-12-20', '0', '77', '1', '07340', '0', '0', '0', '0', '0', '330','330','330','330','330','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','330','330','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16528, 1,'2024-12-20 16:52:39',77)
                ON DUPLICATE KEY UPDATE productid = 16528, edited = 1, sysdate = '2024-12-20 16:52:39', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16528', '1', '2024-12-20', '77', '0','1652801','380','380','380','330','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16528', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16528', '1', '0', '0', '16528', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE productunit SET unitid = '1', productid = '16454', productnumber = '1.00', productunitdate = '2024-12-14', userid = '77', conditions = '0',proUnitParcode='1645401',proUnitSellAllPrice='850',proUnitSellHalfPrice='850',proUnitSellUnitPrice ='850',proUnitBuyPrice='735',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16454';
UPDATE product SET productName = '7305', productDescription = '', productCatId = '5', productBuyPrice = '745', productSellAllPrice = '810', productSellUnitPrice = '810', productSellHalfPrice = '810', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = '07305',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '735.00',lastbuyprice_withDiscount = '735',meanbuyprice = '741',meanbuyprice_withDiscount = '741' , productbuypricereal = '745' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='740',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='735',meanbuyprice_withTax='739',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='735'  WHERE productId = '16454';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:23:05";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:53:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:53:05', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658464dc3af
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:51:16', '067658464dc3af', '1', '0.00', '0', '0', '1', '410.00', '410', '410', '0', '1', '2024-12-20 16:53:05', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','410','0','','0','0','410','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150442', '0', '2024-12-20 16:53:05', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '410', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 16:51:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36353;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','H1589', '150442', '14', '16167', '1', '410', '410', '0', '', '1', '2024-12-20 16:53:05', '16167', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36353-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 349.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 349.00
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 349, lastbuyprice_withDiscountAndTax = 350
                where sellbilldetailid = 549659;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16167, '2024-12-20', 410, 350, 350
                    , 349, 350, 349, 347
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 350, 349, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+349
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+349
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+347
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+349
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 410, 350, 350
                    , 349, 350, 349, 347
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 349, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+349
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+349
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+347
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+349
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '104', storedetaildate = '2024-12-20 16:53:05' WHERE storedetailid = '16166';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16167', '1', '1', '1', '150442', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '104', '2024-12-20 16:53:05','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '35390',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('34980','410', '0', '1', 'اضافة فاتورة مبيعات', '150442', '35390', '2024-12-20 16:53:05', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 410, 350, 350
                    , 349, 350, 349, 347
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 349, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+349
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+349
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+347
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+349
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 410, 350, 350
                    , 349, 350, 349, 347
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 349, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+349
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+349
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+347
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+349
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 410, 350, 350
                    , 349, 350, 349, 347, 350, 349)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+410, netSellCostBuyPrice = netSellCostBuyPrice+350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+349
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+350
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+349
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+347
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+350
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+349;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658464dc3af and sellbillId = 150442 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:23:06";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:53:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:53:06', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:23:19";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:53:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:53:19', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248013
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1236,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '165' , clientdate = '2024-12-20 16:53:19', userid = '2' WHERE clientid = '1236';
UPDATE client SET  inUse = 0 where clientid = 1236;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1236','4959.00','4794','1','ايصال تحصيل (( قبض من عميل ))','248013', '165', '2024-12-20 16:52:16', '2', 'clientPayedDeptController.php', '   ', '4794', '0', null, '0', null, null,'', '-1','1','1','4794','1','','3662','0');
UPDATE save SET  savecurrentvalue = '152176.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('147382.50','4794', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248014', '152176.5', '2024-12-20 16:53:19', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '4794', '4794', '2024-12-20', '2', '0', '0', '2024-12-20 16:53:20','اضافة ايصال سداد للعميل ايمان محمد القناطر 14','1','0','0','0','248014','clientPayedDeptController.php?do=show&id=248014');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122325', '-1', '4794', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '4794', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122325', '-1', '4794', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-4794', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '1236', clientdebtchangebefore = '4959.000', clientdebtchangeamount = '4794.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248013', clientdebtchangeafter = '165.000', clientdebtchangedate = '2024-12-20 16:52:16', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '4794.00',discount='', reciptid='0', dailyentryid = '122325',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='4794',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248014';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248013 -clientdebtchangeId = 248014
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:23:20";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:53:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:53:20', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:23:24";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:53:24", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 16:53:24', '77', '', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:23:42";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:53:42", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:53:42', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676583e088dbf
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10775,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:49:04', '0676583e088dbf', '10775', '0.00', '1475', '0', '1', '1475.00', '1475', '0', '1475', '1', '2024-12-20 16:53:42', '', '75', '0', 'حسناء عبداللة 33', '2', '1', '3', '89', 'حسناء عبداللة 33', '9' ,'0','','','','','-1','0','0','0','0','0','1475','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1475', userid = '75' WHERE clientid = '10775';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10775','0.00','1475','0','اضافة فاتورة مبيعات','150443', '1475', '2024-12-20 16:53:42', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1475', '0', null, '0', null, null,'', '0','1','1','1475','1','2024-12-20 16:49:04','0','0');
UPDATE client SET  inUse = 0 where clientid = 10775;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('320','06712', '150443', '5', '15227', '1', '320', '320', '0', '', '1', '2024-12-20 16:53:43', '15227', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
        , lastbuyprice_withTax = 320, meanbuyprice_withTax = 960, lastbuyprice_withDiscountAndTax = 320
                where sellbilldetailid = 549660;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15227, '2024-12-20', 320, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 320, 960, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+320
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+960
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 960, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+320
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+960
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-14', userid = '75', storedetaildate = '2024-12-20 16:53:43' WHERE storedetailid = '15226';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15227', '1', '1', '1', '150443', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-13', '-14', '75', '2024-12-20 16:53:43','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('285','05480', '150443', '5', '11925', '1', '195', '195', '0', '', '1', '2024-12-20 16:53:43', '11925', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','195','195','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 285.00 , meanbuyprice = 283.00, lastbuyprice_withDiscount = 285.00, meanbuyprice_withDiscount = 283.00
        
                where sellbilldetailid = 549661;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11925, '2024-12-20', 195, 285, 285
                    , 283, 285, 283, 281.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+195, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+283
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+283
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+281.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 195, 285, 285
                    , 283, 285, 283, 281.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+195, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+283
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+283
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+281.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-4', userid = '75', storedetaildate = '2024-12-20 16:53:43' WHERE storedetailid = '11924';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11925', '1', '1', '1', '150443', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-3', '-4', '75', '2024-12-20 16:53:43','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31371;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('230','R2809', '150443', '1', '14026', '1', '170', '170', '0', '', '1', '2024-12-20 16:53:43', '14026', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31371-1,','1','1','0','0','170','170','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        
                where sellbilldetailid = 549662;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14026, '2024-12-20', 170, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 170, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '75', storedetaildate = '2024-12-20 16:53:43' WHERE storedetailid = '14025';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14026', '1', '1', '1', '150443', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-20 16:53:43','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('185','06497', '150443', '5', '14828', '1', '130', '130', '0', '', '1', '2024-12-20 16:53:43', '14828', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','130','130','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 185.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 185.00
        
                where sellbilldetailid = 549663;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14828, '2024-12-20', 130, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+185
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 130, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+185
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 16:53:43' WHERE storedetailid = '14827';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14828', '1', '1', '1', '150443', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 16:53:43','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31324;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','R2819', '150443', '1', '14057', '1', '155', '155', '0', '', '1', '2024-12-20 16:53:43', '14057', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31324-1,','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        
                where sellbilldetailid = 549664;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14057, '2024-12-20', 155, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '75', storedetaildate = '2024-12-20 16:53:43' WHERE storedetailid = '14056';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14057', '1', '1', '1', '150443', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-20 16:53:43','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('210','R2832', '150443', '1', '14141', '1', '125', '125', '0', '', '1', '2024-12-20 16:53:43', '14141', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','125','125','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
        
                where sellbilldetailid = 549665;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14141, '2024-12-20', 125, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+210
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 125, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+210
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-20 16:53:43' WHERE storedetailid = '14140';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14141', '1', '1', '1', '150443', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-20 16:53:43','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31622;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('380','06248', '150443', '5', '14224', '1', '345', '345', '0', '', '1', '2024-12-20 16:53:43', '14224', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31622-1,','1','1','0','0','345','345','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 380.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 380.00
        
                where sellbilldetailid = 549666;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14224, '2024-12-20', 345, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+345, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 345, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+345, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 16:53:43' WHERE storedetailid = '14223';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14224', '1', '1', '1', '150443', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-20 16:53:43','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150443', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 16:53:43', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150443', '17', '10291', '1', '15', '15', '0', '', '1', '2024-12-20 16:53:43', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','15','15','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 89 where clientid = 10775;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1475, 1810, 1810
                    , 1808, 1810, 1808, 1806.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,320, 960, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1475, sellCostBuyPrice =sellCostBuyPrice+1810
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1810, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1808
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1810, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1808
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1806.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+320
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+960
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10775, '2024-12-20', 1475, 1810, 1810
                    , 1808, 1810, 1808, 1806.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,320, 960, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1475, sellCostBuyPrice =sellCostBuyPrice+1810
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1810, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1808
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1810, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1808
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1806.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+320
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+960
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1475, 1810, 1810
                    , 1808, 1810, 1808, 1806.67, 320, 960)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1475, netSellCostBuyPrice = netSellCostBuyPrice+1810
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1810
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1808
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1810
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1808
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1806.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+320
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+960;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676583e088dbf and sellbillId = 150443 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:23:43";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 16:53:43", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:53:43', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:23:45";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:53:45", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 16:53:45', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:23:49";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:53:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:53:49', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248015
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(235,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '101' , clientdate = '2024-12-20 16:53:49', userid = '2' WHERE clientid = '235';
UPDATE client SET  inUse = 0 where clientid = 235;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('235','161.00','60','1','ايصال تحصيل (( قبض من عميل ))','248015', '101', '2024-12-20 16:53:20', '2', 'clientPayedDeptController.php', '   ', '60', '0', null, '0', null, null,'', '-1','1','1','60','1','','3663','0');
UPDATE save SET  savecurrentvalue = '152236.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('152176.50','60', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248016', '152236.5', '2024-12-20 16:53:49', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '60', '60', '2024-12-20', '2', '0', '0', '2024-12-20 16:53:49','اضافة ايصال سداد للعميل لمياء حداد i71','1','0','0','0','248016','clientPayedDeptController.php?do=show&id=248016');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122326', '-1', '60', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '60', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122326', '-1', '60', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-60', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '235', clientdebtchangebefore = '161.000', clientdebtchangeamount = '60.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248015', clientdebtchangeafter = '101.000', clientdebtchangedate = '2024-12-20 16:53:20', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '60.00',discount='', reciptid='0', dailyentryid = '122326',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='60',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248016';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248015 -clientdebtchangeId = 248016
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:23:50";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:53:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:53:50', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:24:01";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:54:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:54:01', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:24:18";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:54:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:54:18', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:24:31";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:54:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:54:31', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=add');
BEGIN;
INSERT INTO transfermoney (saveidfrom, saveidto, transfermoneyvalue, transfermoneydate, userid, conditions, dailyentryid , comment,currencyId,conversionFactor,conversionFactorFrom,conversionFactorTo,transfermoneyvalueInCurrency) VALUES ('1','8', '20000', '2024-12-20', '104', '0', '0','','1','1','0','0','20000');
UPDATE save SET  savecurrentvalue = '15390',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('35390.00','20000', '1', '1', 'تحويل امول الى الخزنة  [ شيكات وكمبيالات ] ', '3536', '15390', '2024-12-20 16:54:31', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '675000',  userid = '104' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('655000.00','20000', '0', '8', 'تحويل امول من الخزنة  [ نقدي ] ', '3536', '675000', '2024-12-20 16:54:31', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '8', transfermoneyvalue = '20000.00', transfermoneydate = '2024-12-20', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='20000' WHERE transfermoneyid = '3536';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:24:32";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:54:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:54:32', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:24:33";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:54:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:54:34', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7343','','5','240','300', '300','300', '2024-12-20', '0', '77', '1', '07343', '0', '0', '0', '0', '0', '240','240','240','240','240','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','240','240','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16529, 1,'2024-12-20 16:54:37',77)
                ON DUPLICATE KEY UPDATE productid = 16529, edited = 1, sysdate = '2024-12-20 16:54:37', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16529', '1', '2024-12-20', '77', '0','1652901','300','300','300','240','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16529', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16529', '1', '0', '0', '16529', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:24:41";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:54:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:54:41', '2', 'remove', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=remove&id=247946&action=122302');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController delete - with clientdebtchangeId =247946
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9659,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '1929', userid = '2' WHERE clientid = '9659';
UPDATE client SET  inUse = 0 where clientid = 9659;
UPDATE clientdebtchange SET del='1' WHERE clientdebtchangeid = '247946';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid, del,dailyentryid , num , billid ,paytype,seller,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments) VALUES ('9659','9.00','1920.000','0','الغاء سداد ديون عميل','247946', '1929', '2024-12-20 16:54:41', '2', 'clientPayedDeptController.php', '', '1920', '0', null, '1', '122302', null, null,'','0','1','1','1920','1','','0','0');
UPDATE save SET  savecurrentvalue = '150316.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('152236.50','1920', '1', '2', 'الغاء سداد ديون عميل', '248017', '150316.5', '2024-12-20 16:54:41', '2',  'clientPayedDeptController.php','0','','0');
UPDATE dailyentry SET totalcreditor = '1920.00', totaldebtor = '1920.00', thedate = '2024-12-20', userid = '2', `condition` = '0', reverseofid = '-10', dDateTime = '2024-12-20 15:53:10', entryComment = 'اضافة ايصال سداد للعميل مروة عبد السميع 12', fromFlag = '1',related='0',isopeningentry='0',operationId='247946',operationDetailLink='clientPayedDeptController.php?do=show&id=247946' WHERE id = '122302';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1920.00', '1920.00', '2024-12-20', '2', '0', '122302', '2024-12-20 16:54:41','تم عكس القيد رقم 122302 ','1','0','0','0','0','');
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122327', '-1', '1920.00', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1920', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122327', '12612', '1920.00', '','0');
UPDATE accountstree SET name = 'مروة عبد السميع 12', customName = 'مروة عبد السميع 12', customNameEn = 'مروة عبد السميع 12', nameEn = 'مروة عبد السميع 12', parent = '58', accountNature = '0', theValue = '9', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 15:53:10' WHERE id = '12612';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController delete end - with clientdebtchangeId =247946
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:24:42";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:54:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:54:42', '2', 'sucess', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:24:44";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:54:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:54:44', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:24:46";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:54:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:54:46', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:01";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:55:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:55:01', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:06";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:55:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:55:06', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248018
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9659,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 16:55:06', userid = '2' WHERE clientid = '9659';
UPDATE client SET  inUse = 0 where clientid = 9659;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9659','1929.00','1929','1','ايصال تحصيل (( قبض من عميل ))','248018', '0', '2024-12-20 16:54:46', '2', 'clientPayedDeptController.php', '   ', '1929', '0', null, '0', null, null,'', '-1','1','1','1929','1','','3664','0');
UPDATE save SET  savecurrentvalue = '152245.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('150316.50','1929', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248018', '152245.5', '2024-12-20 16:55:06', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1929', '1929', '2024-12-20', '2', '0', '0', '2024-12-20 16:55:06','اضافة ايصال سداد للعميل مروة عبد السميع 12','1','0','0','0','248018','clientPayedDeptController.php?do=show&id=248018');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122328', '-1', '1929', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1929', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122328', '-1', '1929', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1929', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '9659', clientdebtchangebefore = '1929.000', clientdebtchangeamount = '1929.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248018', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 16:54:46', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1929.00',discount='', reciptid='0', dailyentryid = '122328',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1929',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248018';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248018 -clientdebtchangeId = 248018
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:07";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:55:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:55:07', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:10";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:55:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:55:10', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=add');
BEGIN;
INSERT INTO transfermoney (saveidfrom, saveidto, transfermoneyvalue, transfermoneydate, userid, conditions, dailyentryid , comment,currencyId,conversionFactor,conversionFactorFrom,conversionFactorTo,transfermoneyvalueInCurrency) VALUES ('1','5', '5000', '2024-12-20', '104', '0', '0','','1','1','0','0','5000');
UPDATE save SET  savecurrentvalue = '10390',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('15390.00','5000', '1', '1', 'تحويل امول الى الخزنة  [ جمعيه ] ', '3537', '10390', '2024-12-20 16:55:10', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '55000',  userid = '104' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('50000.00','5000', '0', '5', 'تحويل امول من الخزنة  [ نقدي ] ', '3537', '55000', '2024-12-20 16:55:10', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '5', transfermoneyvalue = '5000.00', transfermoneydate = '2024-12-20', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='5000' WHERE transfermoneyid = '3537';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:10";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:55:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:55:10', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:12";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:55:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:55:12', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:20";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:55:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:55:20', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:39";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:55:39", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:55:39', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('067658466c5e99', '2024-12-20 16:51:18', '80', '261725.00', '307575', '0', '0', '45850',  '45850', '0', '45850', '1', '2024-12-20 16:55:39', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07344', '14175', '5', '16526', '10', '550', '5500', '0', '', '2024-12-20 16:55:39', '16526','','','0','0','0','0','0',null,'550','5500','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:51:18', 1, 16526, 0, 0
                    , 550, 10, 0, 0, 77, '2024-12-20 16:55:39')
                ON DUPLICATE KEY UPDATE buyprice = 550,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:55:39' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16526', '550', '10', '0', 'buyBillController.php', '32799', '', '0', '0');
UPDATE product SET  productBuyPrice = "550" WHERE productId = 16526 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32799 ;
UPDATE product SET productName = '7344', productDescription = '', productCatId = '5', productBuyPrice = '550.00', productSellAllPrice = '620.00', productSellUnitPrice = '620.00', productSellHalfPrice = '620.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07344',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '550',lastbuyprice_withDiscount = '550',meanbuyprice = '550',meanbuyprice_withDiscount = '550' , productbuypricereal = '550.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='550',meanbuyprice_withTax='550',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='550'  WHERE productId = '16526';
UPDATE buybilldetail SET  lastbuyprice = 550 , meanbuyprice = 550, lastbuyprice_withDiscount = 550, meanbuyprice_withDiscount = 550
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 550, lastbuyprice_withDiscountAndTax = 550
                where buybilldetailid = 32799;
UPDATE productunit SET proUnitBuyPrice  = 550 * productnumber WHERE productid = 16526;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16525';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16526', '1', '10', '0', '14175', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-20 16:51:18','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07339', '14175', '5', '16527', '30', '330', '9900', '0', '', '2024-12-20 16:55:39', '16527','','','0','0','0','0','0',null,'330','9900','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:51:18', 1, 16527, 0, 0
                    , 330, 30, 0, 0, 77, '2024-12-20 16:55:39')
                ON DUPLICATE KEY UPDATE buyprice = 330,
                        buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:55:39' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16527', '330', '30', '0', 'buyBillController.php', '32800', '', '0', '0');
UPDATE product SET  productBuyPrice = "330" WHERE productId = 16527 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32800 ;
UPDATE product SET productName = '7339', productDescription = '', productCatId = '5', productBuyPrice = '330.00', productSellAllPrice = '380.00', productSellUnitPrice = '380.00', productSellHalfPrice = '380.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07339',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '330',lastbuyprice_withDiscount = '330',meanbuyprice = '330',meanbuyprice_withDiscount = '330' , productbuypricereal = '330.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='330',meanbuyprice_withTax='330',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='330'  WHERE productId = '16527';
UPDATE buybilldetail SET  lastbuyprice = 330 , meanbuyprice = 330, lastbuyprice_withDiscount = 330, meanbuyprice_withDiscount = 330
        , lastbuyprice_withTax = 330, meanbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 330
                where buybilldetailid = 32800;
UPDATE productunit SET proUnitBuyPrice  = 330 * productnumber WHERE productid = 16527;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16526';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16527', '1', '30', '0', '14175', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '30', '77', '2024-12-20 16:51:18','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07340', '14175', '5', '16528', '15', '330', '4950', '0', '', '2024-12-20 16:55:39', '16528','','','0','0','0','0','0',null,'330','4950','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:51:18', 1, 16528, 0, 0
                    , 330, 15, 0, 0, 77, '2024-12-20 16:55:39')
                ON DUPLICATE KEY UPDATE buyprice = 330,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:55:39' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16528', '330', '15', '0', 'buyBillController.php', '32801', '', '0', '0');
UPDATE product SET  productBuyPrice = "330" WHERE productId = 16528 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32801 ;
UPDATE product SET productName = '7340', productDescription = '', productCatId = '5', productBuyPrice = '330.00', productSellAllPrice = '380.00', productSellUnitPrice = '380.00', productSellHalfPrice = '380.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07340',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '330',lastbuyprice_withDiscount = '330',meanbuyprice = '330',meanbuyprice_withDiscount = '330' , productbuypricereal = '330.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='330',meanbuyprice_withTax='330',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='330'  WHERE productId = '16528';
UPDATE buybilldetail SET  lastbuyprice = 330 , meanbuyprice = 330, lastbuyprice_withDiscount = 330, meanbuyprice_withDiscount = 330
        , lastbuyprice_withTax = 330, meanbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 330
                where buybilldetailid = 32801;
UPDATE productunit SET proUnitBuyPrice  = 330 * productnumber WHERE productid = 16528;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16527';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16528', '1', '15', '0', '14175', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 16:51:18','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07305', '14175', '5', '16454', '15', '745', '11175', '0', '', '2024-12-20 16:55:39', '16454','','','0','0','0','0','0',null,'745','11175','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:51:18', 1, 16454, 0, 0
                    , 745, 15, 0, 0, 77, '2024-12-20 16:55:39')
                ON DUPLICATE KEY UPDATE buyprice = 745,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:55:39' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16454', '745', '15', '0', 'buyBillController.php', '32802', '', '0', '0');
UPDATE product SET  productBuyPrice = "745" WHERE productId = 16454 ;
UPDATE buybilldetail SET  quantitybefore = 22 WHERE buybilldetailid = 32802 ;
UPDATE product SET productName = '7305', productDescription = '', productCatId = '5', productBuyPrice = '745.00', productSellAllPrice = '810.00', productSellUnitPrice = '810.00', productSellHalfPrice = '810.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = '07305',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '745',lastbuyprice_withDiscount = '745',meanbuyprice = '743',meanbuyprice_withDiscount = '743' , productbuypricereal = '745.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='740',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='745',meanbuyprice_withTax='741',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='745'  WHERE productId = '16454';
UPDATE buybilldetail SET  lastbuyprice = 745 , meanbuyprice = 743, lastbuyprice_withDiscount = 745, meanbuyprice_withDiscount = 743
        , lastbuyprice_withTax = 745, meanbuyprice_withTax = 741, lastbuyprice_withDiscountAndTax = 745
                where buybilldetailid = 32802;
UPDATE productunit SET proUnitBuyPrice  = 745 * productnumber WHERE productid = 16454;
UPDATE storedetail SET  productquantity = '37', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16453';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16454', '1', '15', '0', '14175', 'اضافة فاتورة مشتريات', 'buyBillController.php', '22', '37', '77', '2024-12-20 16:51:18','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1644', '14175', '14', '16388', '15', '585', '8775', '0', '', '2024-12-20 16:55:39', '16388','','','0','0','0','0','0',null,'585','8775','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:51:18', 1, 16388, 0, 0
                    , 585, 15, 0, 0, 77, '2024-12-20 16:55:39')
                ON DUPLICATE KEY UPDATE buyprice = 585,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:55:39' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16388', '585', '15', '0', 'buyBillController.php', '32803', '', '0', '0');
UPDATE product SET  productBuyPrice = "585" WHERE productId = 16388 ;
UPDATE buybilldetail SET  quantitybefore = 14 WHERE buybilldetailid = 32803 ;
UPDATE product SET productName = 'H1644', productDescription = '', productCatId = '14', productBuyPrice = '585.00', productSellAllPrice = '700.00', productSellUnitPrice = '700.00', productSellHalfPrice = '700.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1644',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '585',lastbuyprice_withDiscount = '585',meanbuyprice = '585',meanbuyprice_withDiscount = '585' , productbuypricereal = '585.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='585',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='585',meanbuyprice_withTax='585',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='585'  WHERE productId = '16388';
UPDATE buybilldetail SET  lastbuyprice = 585 , meanbuyprice = 585, lastbuyprice_withDiscount = 585, meanbuyprice_withDiscount = 585
        , lastbuyprice_withTax = 585, meanbuyprice_withTax = 585, lastbuyprice_withDiscountAndTax = 585
                where buybilldetailid = 32803;
UPDATE productunit SET proUnitBuyPrice  = 585 * productnumber WHERE productid = 16388;
UPDATE storedetail SET  productquantity = '29', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '15', '0', '14175', 'اضافة فاتورة مشتريات', 'buyBillController.php', '14', '29', '77', '2024-12-20 16:51:18','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07343', '14175', '5', '16529', '10', '240', '2400', '0', '', '2024-12-20 16:55:39', '16529','','','0','0','0','0','0',null,'240','2400','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:51:18', 1, 16529, 0, 0
                    , 240, 10, 0, 0, 77, '2024-12-20 16:55:39')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:55:39' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16529', '240', '10', '0', 'buyBillController.php', '32804', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 16529 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32804 ;
UPDATE product SET productName = '7343', productDescription = '', productCatId = '5', productBuyPrice = '240.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07343',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '240',lastbuyprice_withDiscount = '240',meanbuyprice = '240',meanbuyprice_withDiscount = '240' , productbuypricereal = '240.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='240',meanbuyprice_withTax='240',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='240'  WHERE productId = '16529';
UPDATE buybilldetail SET  lastbuyprice = 240 , meanbuyprice = 240, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 240
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32804;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16529;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16528';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16529', '1', '10', '0', '14175', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-20 16:51:18','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07289', '14175', '5', '16419', '15', '210', '3150', '0', '', '2024-12-20 16:55:39', '16419','','','0','0','0','0','0',null,'210','3150','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:51:18', 1, 16419, 0, 0
                    , 210, 15, 0, 0, 77, '2024-12-20 16:55:39')
                ON DUPLICATE KEY UPDATE buyprice = 210,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:55:39' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16419', '210', '15', '0', 'buyBillController.php', '32805', '', '0', '0');
UPDATE product SET  productBuyPrice = "210" WHERE productId = 16419 ;
UPDATE buybilldetail SET  quantitybefore = 8 WHERE buybilldetailid = 32805 ;
UPDATE product SET productName = '7289', productDescription = '', productCatId = '5', productBuyPrice = '210.00', productSellAllPrice = '260.00', productSellUnitPrice = '260.00', productSellHalfPrice = '260.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07289',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210',lastbuyprice_withDiscount = '210',meanbuyprice = '210',meanbuyprice_withDiscount = '210' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='210',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='210',meanbuyprice_withTax='210',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='210'  WHERE productId = '16419';
UPDATE buybilldetail SET  lastbuyprice = 210 , meanbuyprice = 210, lastbuyprice_withDiscount = 210, meanbuyprice_withDiscount = 210
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where buybilldetailid = 32805;
UPDATE productunit SET proUnitBuyPrice  = 210 * productnumber WHERE productid = 16419;
UPDATE storedetail SET  productquantity = '23', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16418';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16419', '1', '15', '0', '14175', 'اضافة فاتورة مشتريات', 'buyBillController.php', '8', '23', '77', '2024-12-20 16:51:18','0','0');
UPDATE supplier SET  suppliercurrentDebt = '307575',suppliercurrentDebtInCurrency= '307575' , userid = '77', supplierdate = '2024-12-20 16:55:39'   WHERE supplierid = '80';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('80', '261725.00', '45850', '0', 'اضافة فاتورة مشتريات', '14175', '307575', '2024-12-20 16:51:18', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','45850','1','261725','45850','307575','0');
update buybill set dailyentryid='0,' where buybillid=14175;
COMMIT;
UPDATE product SET overAllAveragePrice = 585 WHERE productId = 16388;UPDATE product SET overAllAveragePrice = 210 WHERE productId = 16419;UPDATE product SET overAllAveragePrice = 741.67 WHERE productId = 16454;UPDATE product SET overAllAveragePrice = 550 WHERE productId = 16526;UPDATE product SET overAllAveragePrice = 330 WHERE productId = 16527;UPDATE product SET overAllAveragePrice = 330 WHERE productId = 16528;UPDATE product SET overAllAveragePrice = 240 WHERE productId = 16529;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:39";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:55:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:55:39', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:40";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:55:40", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:55:40', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14175');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:45";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:55:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:55:45', '104', 'edit', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=edit&transfermoneyid=3537');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:51";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:55:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:55:51', '104', 'update', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=update');
BEGIN;
UPDATE transfermoney SET saveidfrom = '1', saveidto = '5', transfermoneyvalue = '5000.00', transfermoneydate = '2024-12-20', userid = '104', conditions = '2' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='5000' WHERE transfermoneyid = '3537';
UPDATE save SET  savecurrentvalue = '50000',  userid = '104' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('55000.00','5000', '1', '5', 'الغاء تحويل امول من الخزنة  [ نقدي ] ', '3537', '50000', '2024-12-20 16:55:51', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '15390',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('10390.00','5000', '0', '1', 'الغاء تحويل امول الى الخزنة  [ جمعيه ] ', '3537', '15390', '2024-12-20 16:55:51', '104',  'transfermoneyController.php','0','','0');
COMMIT;
BEGIN;
INSERT INTO transfermoney (saveidfrom, saveidto, transfermoneyvalue, transfermoneydate, userid, conditions, dailyentryid , comment,currencyId,conversionFactor,conversionFactorFrom,conversionFactorTo,transfermoneyvalueInCurrency) VALUES ('1','5', '10000', '2024-12-20', '104', '0', '0','','1','1','0','0','10000');
UPDATE save SET  savecurrentvalue = '5390',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('15390.00','10000', '1', '1', 'تحويل امول الى الخزنة  [ جمعيه ] ', '3538', '5390', '2024-12-20 16:55:51', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '60000',  userid = '104' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('50000.00','10000', '0', '5', 'تحويل امول من الخزنة  [ نقدي ] ', '3538', '60000', '2024-12-20 16:55:51', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '5', transfermoneyvalue = '10000.00', transfermoneydate = '2024-12-20', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='10000' WHERE transfermoneyid = '3538';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:52";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:55:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:55:52', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:53";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:55:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:55:53', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:25:55";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:55:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:55:55', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:26:11";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:56:11", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:56:11', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248019
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3507,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 16:56:11', userid = '2' WHERE clientid = '3507';
UPDATE client SET  inUse = 0 where clientid = 3507;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3507','930.00','930','1','ايصال تحصيل (( قبض من عميل ))','248019', '0', '2024-12-20 16:55:07', '2', 'clientPayedDeptController.php', '   ', '930', '0', null, '0', null, null,'', '-1','1','1','930','1','','3665','0');
UPDATE save SET  savecurrentvalue = '153175.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('152245.50','930', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248019', '153175.5', '2024-12-20 16:56:11', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '930', '930', '2024-12-20', '2', '0', '0', '2024-12-20 16:56:11','اضافة ايصال سداد للعميل هيلينا خليل B1052','1','0','0','0','248019','clientPayedDeptController.php?do=show&id=248019');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122329', '-1', '930', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '930', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122329', '-1', '930', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-930', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '3507', clientdebtchangebefore = '930.000', clientdebtchangeamount = '930.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248019', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 16:55:07', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '930.00',discount='', reciptid='0', dailyentryid = '122329',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='930',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248019';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248019 -clientdebtchangeId = 248019
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:26:12";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:56:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:56:12', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:26:30";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:56:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:56:30', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:26:36";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:56:36", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:56:36', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:26:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:56:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:56:46', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248020
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1815,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 16:56:46', userid = '104' WHERE clientid = '1815';
UPDATE client SET  inUse = 0 where clientid = 1815;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1815','1360.00','1360','1','ايصال تحصيل (( قبض من عميل ))','248020', '0', '2024-12-20 16:56:31', '104', 'clientPayedDeptController.php', '   ', '1360', '0', null, '0', null, null,'', '-1','1','1','1360','1','','3666','0');
UPDATE save SET  savecurrentvalue = '6750',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('5390.00','1360', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '248020', '6750', '2024-12-20 16:56:46', '104',  'clientPayedDeptController.php','0','','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('حنان مبارك 58', 'حنان مبارك 58', 'حنان مبارك 58', 'حنان مبارك 58', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '104', '0', '2024-12-20 16:56:47');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1360', '1360', '2024-12-20', '104', '0', '0', '2024-12-20 16:56:47','اضافة ايصال سداد للعميل حنان مبارك 58','1','0','-1','0','248020','clientPayedDeptController.php?do=show&id=248020');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122330', '-1', '1360', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1360', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122330', '12620', '1360', '','0');
UPDATE accountstree SET name = 'حنان مبارك 58', customName = 'حنان مبارك 58', customNameEn = 'حنان مبارك 58', nameEn = 'حنان مبارك 58', parent = '58', accountNature = '0', theValue = '-1360', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '104', del = '0', sysdate = '2024-12-20 16:56:47' WHERE id = '12620';
UPDATE clientdebtchange SET clientid = '1815', clientdebtchangebefore = '1360.000', clientdebtchangeamount = '1360.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248020', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 16:56:31', userid = '104', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1360.00',discount='', reciptid='0', dailyentryid = '122330',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1360',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248020';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248020 -clientdebtchangeId = 248020
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:26:47";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:56:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:56:47', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:26:49";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:56:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:56:49', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:26:50";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 16:56:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 16:56:50', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7351','','5','275','335', '335','335', '2024-12-20', '0', '77', '1', '07351', '0', '0', '0', '0', '0', '275','275','275','275','275','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','275','275','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16530, 1,'2024-12-20 16:56:57',77)
                ON DUPLICATE KEY UPDATE productid = 16530, edited = 1, sysdate = '2024-12-20 16:56:57', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16530', '1', '2024-12-20', '77', '0','1653001','335','335','335','275','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16530', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16530', '1', '0', '0', '16530', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('H1694','','14','500','600', '600','600', '2024-12-20', '0', '77', '1', 'H1694', '0', '0', '0', '0', '0', '500','500','500','500','500','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','500','500','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16531, 1,'2024-12-20 16:57:17',77)
                ON DUPLICATE KEY UPDATE productid = 16531, edited = 1, sysdate = '2024-12-20 16:57:17', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16531', '1', '2024-12-20', '77', '0','1653101','600','600','600','500','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16531', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16531', '1', '0', '0', '16531', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7350','','5','300','400', '400','400', '2024-12-20', '0', '77', '1', '07350', '0', '0', '0', '0', '0', '300','300','300','300','300','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','300','300','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16532, 1,'2024-12-20 16:57:38',77)
                ON DUPLICATE KEY UPDATE productid = 16532, edited = 1, sysdate = '2024-12-20 16:57:38', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16532', '1', '2024-12-20', '77', '0','1653201','400','400','400','300','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16532', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16532', '1', '0', '0', '16532', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:27:45";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:57:45", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:57:45', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('0676585a4eb0f6', '2024-12-20 16:56:36', '80', '307575.00', '321200', '0', '0', '13625',  '13625', '0', '13625', '1', '2024-12-20 16:57:45', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07351', '14176', '5', '16530', '15', '275', '4125', '0', '', '2024-12-20 16:57:45', '16530','','','0','0','0','0','0',null,'275','4125','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:56:36', 1, 16530, 0, 0
                    , 275, 15, 0, 0, 77, '2024-12-20 16:57:45')
                ON DUPLICATE KEY UPDATE buyprice = 275,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:57:45' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16530', '275', '15', '0', 'buyBillController.php', '32806', '', '0', '0');
UPDATE product SET  productBuyPrice = "275" WHERE productId = 16530 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32806 ;
UPDATE product SET productName = '7351', productDescription = '', productCatId = '5', productBuyPrice = '275.00', productSellAllPrice = '335.00', productSellUnitPrice = '335.00', productSellHalfPrice = '335.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07351',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '275',lastbuyprice_withDiscount = '275',meanbuyprice = '275',meanbuyprice_withDiscount = '275' , productbuypricereal = '275.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='275',meanbuyprice_withTax='275',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='275'  WHERE productId = '16530';
UPDATE buybilldetail SET  lastbuyprice = 275 , meanbuyprice = 275, lastbuyprice_withDiscount = 275, meanbuyprice_withDiscount = 275
        , lastbuyprice_withTax = 275, meanbuyprice_withTax = 275, lastbuyprice_withDiscountAndTax = 275
                where buybilldetailid = 32806;
UPDATE productunit SET proUnitBuyPrice  = 275 * productnumber WHERE productid = 16530;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16529';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16530', '1', '15', '0', '14176', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 16:56:36','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1694', '14176', '14', '16531', '10', '500', '5000', '0', '', '2024-12-20 16:57:45', '16531','','','0','0','0','0','0',null,'500','5000','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:56:36', 1, 16531, 0, 0
                    , 500, 10, 0, 0, 77, '2024-12-20 16:57:45')
                ON DUPLICATE KEY UPDATE buyprice = 500,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:57:45' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16531', '500', '10', '0', 'buyBillController.php', '32807', '', '0', '0');
UPDATE product SET  productBuyPrice = "500" WHERE productId = 16531 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32807 ;
UPDATE product SET productName = 'H1694', productDescription = '', productCatId = '14', productBuyPrice = '500.00', productSellAllPrice = '600.00', productSellUnitPrice = '600.00', productSellHalfPrice = '600.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1694',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '500',lastbuyprice_withDiscount = '500',meanbuyprice = '500',meanbuyprice_withDiscount = '500' , productbuypricereal = '500.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='500',meanbuyprice_withTax='500',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='500'  WHERE productId = '16531';
UPDATE buybilldetail SET  lastbuyprice = 500 , meanbuyprice = 500, lastbuyprice_withDiscount = 500, meanbuyprice_withDiscount = 500
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 500, lastbuyprice_withDiscountAndTax = 500
                where buybilldetailid = 32807;
UPDATE productunit SET proUnitBuyPrice  = 500 * productnumber WHERE productid = 16531;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16530';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16531', '1', '10', '0', '14176', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-20 16:56:36','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07350', '14176', '5', '16532', '15', '300', '4500', '0', '', '2024-12-20 16:57:45', '16532','','','0','0','0','0','0',null,'300','4500','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 16:56:36', 1, 16532, 0, 0
                    , 300, 15, 0, 0, 77, '2024-12-20 16:57:45')
                ON DUPLICATE KEY UPDATE buyprice = 300,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 16:57:45' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16532', '300', '15', '0', 'buyBillController.php', '32808', '', '0', '0');
UPDATE product SET  productBuyPrice = "300" WHERE productId = 16532 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32808 ;
UPDATE product SET productName = '7350', productDescription = '', productCatId = '5', productBuyPrice = '300.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07350',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '300',lastbuyprice_withDiscount = '300',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '300.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='300',meanbuyprice_withTax='300',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='300'  WHERE productId = '16532';
UPDATE buybilldetail SET  lastbuyprice = 300 , meanbuyprice = 300, lastbuyprice_withDiscount = 300, meanbuyprice_withDiscount = 300
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 300, lastbuyprice_withDiscountAndTax = 300
                where buybilldetailid = 32808;
UPDATE productunit SET proUnitBuyPrice  = 300 * productnumber WHERE productid = 16532;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16531';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16532', '1', '15', '0', '14176', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 16:56:36','0','0');
UPDATE supplier SET  suppliercurrentDebt = '321200',suppliercurrentDebtInCurrency= '321200' , userid = '77', supplierdate = '2024-12-20 16:57:45'   WHERE supplierid = '80';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('80', '307575.00', '13625', '0', 'اضافة فاتورة مشتريات', '14176', '321200', '2024-12-20 16:56:36', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','13625','1','307575','13625','321200','0');
update buybill set dailyentryid='0,' where buybillid=14176;
COMMIT;
UPDATE product SET overAllAveragePrice = 275 WHERE productId = 16530;UPDATE product SET overAllAveragePrice = 500 WHERE productId = 16531;UPDATE product SET overAllAveragePrice = 300 WHERE productId = 16532;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:27:46";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:57:46", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:57:46', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14176');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:27:58";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:57:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:57:58', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248020
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2665,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '22' , clientdate = '2024-12-20 16:57:58', userid = '2' WHERE clientid = '2665';
UPDATE client SET  inUse = 0 where clientid = 2665;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2665','345.00','323','1','ايصال تحصيل (( قبض من عميل ))','248020', '22', '2024-12-20 16:56:12', '2', 'clientPayedDeptController.php', '   ', '323', '0', null, '0', null, null,'', '-1','1','1','323','1','','3666','0');
UPDATE save SET  savecurrentvalue = '153498.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('153175.50','323', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248021', '153498.5', '2024-12-20 16:57:58', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '323', '323', '2024-12-20', '2', '0', '0', '2024-12-20 16:57:58','اضافة ايصال سداد للعميل منة حمدي u730','1','0','0','0','248021','clientPayedDeptController.php?do=show&id=248021');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122331', '-1', '323', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '323', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122331', '-1', '323', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-323', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '2665', clientdebtchangebefore = '345.000', clientdebtchangeamount = '323.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248020', clientdebtchangeafter = '22.000', clientdebtchangedate = '2024-12-20 16:56:12', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '323.00',discount='', reciptid='0', dailyentryid = '122331',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='323',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248021';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248020 -clientdebtchangeId = 248021
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:27:59";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:57:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 16:57:59', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:28:25";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:58:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 16:58:25', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:28:30";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 16:58:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 16:58:30', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150009');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:29:22";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:59:22", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:59:22', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:29:55";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:59:55", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 16:59:55', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('06765864a472b1', '2024-12-20 16:59:22', '80', '321200.00', '307250', '0', '0', '-13950', '-13950', '0', '-13950', '1', '2024-12-20 16:59:55', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07313', '2527', '5', '16475', '15', '210', '3150', '0', '', '16475','','','0','0','0','0','0','210','3150','0','0','0','0','0','0','0');
UPDATE product SET productName = '7313', productDescription = '', productCatId = '5', productBuyPrice = '210.00', productSellAllPrice = '260.00', productSellUnitPrice = '260.00', productSellHalfPrice = '260.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07313',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210',lastbuyprice_withDiscount = '210',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='210',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='210',meanbuyprice_withTax='0',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='210'  WHERE productId = '16475';
UPDATE returnbuybilldetail SET  lastbuyprice = 210 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210, meanbuyprice_withDiscount = 210.00
        , lastbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where returnbuybilldetailid = 3960;
UPDATE productunit SET proUnitBuyPrice  = 210 * productnumber WHERE productid = 16475;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16474';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16475', '1', '15', '1', '2527', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '15', '0', '77', '2024-12-20 16:59:22','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07251', '2527', '5', '16371', '15', '360', '5400', '0', '', '16371','','','0','0','0','0','0','360','5400','0','0','0','0','0','0','0');
UPDATE product SET productName = '7251', productDescription = '', productCatId = '5', productBuyPrice = '360.00', productSellAllPrice = '420.00', productSellUnitPrice = '420.00', productSellHalfPrice = '420.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07251',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '360',lastbuyprice_withDiscount = '360',meanbuyprice = '360',meanbuyprice_withDiscount = '360' , productbuypricereal = '360.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='360',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='360',meanbuyprice_withTax='360',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='360'  WHERE productId = '16371';
UPDATE returnbuybilldetail SET  lastbuyprice = 360 , meanbuyprice = 360, lastbuyprice_withDiscount = 360, meanbuyprice_withDiscount = 360
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where returnbuybilldetailid = 3961;
UPDATE productunit SET proUnitBuyPrice  = 360 * productnumber WHERE productid = 16371;
UPDATE storedetail SET  productquantity = '13', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16370';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16371', '1', '15', '1', '2527', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '28', '13', '77', '2024-12-20 16:59:22','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07253', '2527', '5', '16370', '15', '360', '5400', '0', '', '16370','','','0','0','0','0','0','360','5400','0','0','0','0','0','0','0');
UPDATE product SET productName = '7253', productDescription = '', productCatId = '5', productBuyPrice = '360.00', productSellAllPrice = '420.00', productSellUnitPrice = '420.00', productSellHalfPrice = '420.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07253',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '360',lastbuyprice_withDiscount = '360',meanbuyprice = '360',meanbuyprice_withDiscount = '360' , productbuypricereal = '360.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='360',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='360',meanbuyprice_withTax='360',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='360'  WHERE productId = '16370';
UPDATE returnbuybilldetail SET  lastbuyprice = 360 , meanbuyprice = 360, lastbuyprice_withDiscount = 360, meanbuyprice_withDiscount = 360
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where returnbuybilldetailid = 3962;
UPDATE productunit SET proUnitBuyPrice  = 360 * productnumber WHERE productid = 16370;
UPDATE storedetail SET  productquantity = '27', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16369';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16370', '1', '15', '1', '2527', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '42', '27', '77', '2024-12-20 16:59:22','0','0');
UPDATE supplier SET  suppliercurrentDebt = '307250',suppliercurrentDebtInCurrency= '307250' , userid = '77', supplierdate = '2024-12-20 16:59:55'   WHERE supplierid = '80';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('80', '321200.00', '13950', '1', 'اضافة فاتورة مردوات مشتريات', '2527', '307250', '2024-12-20 16:59:22', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','13950','1','321200','13950','307250','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2527;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:29:55";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 16:59:55", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 16:59:55', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2527');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:30:16";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:00:16", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:00:16', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:30:48";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:00:48", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:00:48', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('067658680f3525', '2024-12-20 17:00:16', '80', '307250.00', '302250', '0', '0', '-5000', '-5000', '0', '-5000', '1', '2024-12-20 17:00:48', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07273', '2528', '5', '16395', '10', '500', '5000', '0', '', '16395','','','0','0','0','0','0','500','5000','0','0','0','0','0','0','0');
UPDATE product SET productName = '7273', productDescription = '', productCatId = '5', productBuyPrice = '500.00', productSellAllPrice = '580.00', productSellUnitPrice = '580.00', productSellHalfPrice = '580.00', productDate = '2024-12-11', conditions = '0', userId = '77', limitamount = '1', parcode = '07273',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '500',lastbuyprice_withDiscount = '500',meanbuyprice = '499',meanbuyprice_withDiscount = '499' , productbuypricereal = '510.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='500',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='500',meanbuyprice_withTax='500',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='500'  WHERE productId = '16395';
UPDATE returnbuybilldetail SET  lastbuyprice = 500 , meanbuyprice = 499, lastbuyprice_withDiscount = 500, meanbuyprice_withDiscount = 499
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 500, lastbuyprice_withDiscountAndTax = 500
                where returnbuybilldetailid = 3963;
UPDATE productunit SET proUnitBuyPrice  = 500 * productnumber WHERE productid = 16395;
UPDATE storedetail SET  productquantity = '28', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16394';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16395', '1', '10', '1', '2528', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '38', '28', '77', '2024-12-20 17:00:16','0','0');
UPDATE supplier SET  suppliercurrentDebt = '302250',suppliercurrentDebtInCurrency= '302250' , userid = '77', supplierdate = '2024-12-20 17:00:48'   WHERE supplierid = '80';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('80', '307250.00', '5000', '1', 'اضافة فاتورة مردوات مشتريات', '2528', '302250', '2024-12-20 17:00:16', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','5000','1','307250','5000','302250','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2528;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:30:49";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:00:49", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 17:00:49', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2528');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:31:01";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:01:01", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 17:01:01', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:31:07";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:01:07", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 17:01:07', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:31:25";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:01:25", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:01:25', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:32:37";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:02:37", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:02:37', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676586c576bfd
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7546,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:01:25', '0676586c576bfd', '7546', '0.00', '313', '0', '1', '313.00', '313', '0', '313', '1', '2024-12-20 17:02:37', '', '101', '0', 'ابرار محمد G321', '2', '1', '3', '88', 'ابرار محمد G321', '3' ,'0','','','','','-1','0','0','0','0','0','313','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '313', userid = '101' WHERE clientid = '7546';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7546','0.00','313','0','اضافة فاتورة مبيعات','150444', '313', '2024-12-20 17:02:37', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '313', '0', null, '0', null, null,'', '0','1','1','313','1','2024-12-20 17:01:25','0','0');
UPDATE client SET  inUse = 0 where clientid = 7546;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30213;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('395','06071', '150444', '5', '13546', '1', '290', '290', '0', '', '1', '2024-12-20 17:02:37', '13546', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30213-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 395.00 , meanbuyprice = 395.00, lastbuyprice_withDiscount = 395.00, meanbuyprice_withDiscount = 395.00
        
                where sellbilldetailid = 549669;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13546, '2024-12-20', 290, 395, 395
                    , 395, 395, 395, 395
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+395, sellCostMeanBuyPrice = sellCostMeanBuyPrice+395
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+395
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+395
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 395, 395
                    , 395, 395, 395, 395
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+395, sellCostMeanBuyPrice = sellCostMeanBuyPrice+395
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+395
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+395
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 17:02:37' WHERE storedetailid = '13545';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13546', '1', '1', '1', '150444', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '101', '2024-12-20 17:02:37','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150444', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 17:02:37', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150444', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-20 17:02:37', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','3','3','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 88 where clientid = 7546;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 313, 395, 395
                    , 395, 395, 395, 395
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+313, sellCostBuyPrice =sellCostBuyPrice+395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+395, sellCostMeanBuyPrice = sellCostMeanBuyPrice+395
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+395
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+395
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7546, '2024-12-20', 313, 395, 395
                    , 395, 395, 395, 395
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+313, sellCostBuyPrice =sellCostBuyPrice+395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+395, sellCostMeanBuyPrice = sellCostMeanBuyPrice+395
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+395
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+395
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 313, 395, 395
                    , 395, 395, 395, 395, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+313, netSellCostBuyPrice = netSellCostBuyPrice+395
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+395
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+395
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+395
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+395
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+395
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676586c576bfd and sellbillId = 150444 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:32:38";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:02:38", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:02:38', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:33:29";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 17:03:29", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 17:03:29', '101', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:33:30";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:33:36";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 17:03:36", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:03:36', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:33:43";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 17:03:43", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:03:43', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:34:50";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:04:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:04:50', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:34:53";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:04:53", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:04:53', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676584f821378
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1798,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 16:53:44', '0676584f821378', '1798', '-1991.00', '2500', '105', '1', '4596.00', '4491', '0', '4491', '1', '2024-12-20 17:04:53', '', '75', '0', 'اسماء السيد 43', '2', '1', '3', '91', 'اسماء السيد 43', '22' ,'0','','','','','-1','0','0','0','0','0','4491','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2500', userid = '75' WHERE clientid = '1798';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1798','-1991.00','4491','0','اضافة فاتورة مبيعات','150445', '2500', '2024-12-20 17:04:53', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '4491', '0', null, '0', null, null,'', '0','1','1','4491','1','2024-12-20 16:53:44','0','0');
UPDATE client SET  inUse = 0 where clientid = 1798;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30687;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('375','06052', '150445', '5', '13676', '1', '195', '195', '0', '', '1', '2024-12-20 17:04:53', '13676', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30687-1,','1','1','0','0','195','195','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 375.00 , meanbuyprice = 375.00, lastbuyprice_withDiscount = 375.00, meanbuyprice_withDiscount = 375.00
        
                where sellbilldetailid = 549672;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13676, '2024-12-20', 190.54503916449, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190.54503916449, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+375
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 190.54503916449, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190.54503916449, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+375
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '75', storedetaildate = '2024-12-20 17:04:53' WHERE storedetailid = '13675';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13676', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-20 17:04:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30870;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('340','06139', '150445', '5', '13899', '1', '210', '210', '0', '', '1', '2024-12-20 17:04:53', '13899', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30870-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 340.00 , meanbuyprice = 1267.00, lastbuyprice_withDiscount = 340.00, meanbuyprice_withDiscount = 1267.00
        
                where sellbilldetailid = 549673;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13899, '2024-12-20', 205.20234986945, 340, 340
                    , 1267, 340, 1267, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205.20234986945, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1267
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1267
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 205.20234986945, 340, 340
                    , 1267, 340, 1267, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205.20234986945, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1267
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1267
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 17:04:53' WHERE storedetailid = '13898';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13899', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 17:04:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30951;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('380','06053', '150445', '5', '13871', '1', '245', '245', '0', '', '1', '2024-12-20 17:04:53', '13871', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30951-1,','1','1','0','0','245','245','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 380.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 380.00
        
                where sellbilldetailid = 549674;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13871, '2024-12-20', 239.40274151436, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+239.40274151436, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 239.40274151436, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+239.40274151436, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 17:04:53' WHERE storedetailid = '13870';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13871', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 17:04:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34662;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('245','06809', '150445', '5', '15493', '1', '230', '230', '0', '', '1', '2024-12-20 17:04:53', '15493', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34662-1,','1','1','0','0','230','230','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 245.00 , meanbuyprice = 244.00, lastbuyprice_withDiscount = 245.00, meanbuyprice_withDiscount = 244.00
        , lastbuyprice_withTax = 245, meanbuyprice_withTax = 188, lastbuyprice_withDiscountAndTax = 245
                where sellbilldetailid = 549675;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15493, '2024-12-20', 224.7454308094, 245, 245
                    , 244, 245, 244, 242.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 245, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+224.7454308094, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+244
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+244
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+188
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 224.7454308094, 245, 245
                    , 244, 245, 244, 242.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 245, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+224.7454308094, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+244
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+244
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+188
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '16', userid = '75', storedetaildate = '2024-12-20 17:04:53' WHERE storedetailid = '15492';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15493', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-20 17:04:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34957;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('130','06867', '150445', '5', '15642', '1', '140', '140', '0', '', '1', '2024-12-20 17:04:53', '15642', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34957-1,','1','1','0','0','140','140','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 130.00 , meanbuyprice = 130.00, lastbuyprice_withDiscount = 130.00, meanbuyprice_withDiscount = 130.00
        , lastbuyprice_withTax = 130, meanbuyprice_withTax = 130, lastbuyprice_withDiscountAndTax = 130
                where sellbilldetailid = 549676;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15642, '2024-12-20', 136.80156657963, 130, 130
                    , 130, 130, 130, 130
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 130, 130, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+136.80156657963, sellCostBuyPrice =sellCostBuyPrice+130
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+130, sellCostMeanBuyPrice = sellCostMeanBuyPrice+130
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+130, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+130
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+130
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+130
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+130
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 136.80156657963, 130, 130
                    , 130, 130, 130, 130
                    , 0, 0, 0, 0
                    , 0, 0, 0, 130, 130, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+136.80156657963, sellCostBuyPrice =sellCostBuyPrice+130
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+130, sellCostMeanBuyPrice = sellCostMeanBuyPrice+130
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+130, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+130
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+130
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+130
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+130
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '75', storedetaildate = '2024-12-20 17:04:53' WHERE storedetailid = '15641';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15642', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-20 17:04:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34826;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','06893', '150445', '5', '15665', '1', '155', '155', '0', '', '1', '2024-12-20 17:04:53', '15665', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34826-1,','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549677;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15665, '2024-12-20', 151.4588772846, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+151.4588772846, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 151.4588772846, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+151.4588772846, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '75', storedetaildate = '2024-12-20 17:04:53' WHERE storedetailid = '15664';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15665', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-20 17:04:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36464;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('165','R3336', '150445', '1', '16417', '1', '200', '200', '0', '', '1', '2024-12-20 17:04:53', '16417', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36464-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549678;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16417, '2024-12-20', 195.43080939948, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+195.43080939948, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 195.43080939948, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+195.43080939948, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '75', storedetaildate = '2024-12-20 17:04:53' WHERE storedetailid = '16416';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16417', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-20 17:04:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34641;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','06897', '150445', '5', '15714', '1', '245', '245', '0', '', '1', '2024-12-20 17:04:53', '15714', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34641-1,','1','1','0','0','245','245','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549679;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15714, '2024-12-20', 239.40274151436, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+239.40274151436, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 239.40274151436, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+239.40274151436, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '75', storedetaildate = '2024-12-20 17:04:53' WHERE storedetailid = '15713';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15714', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-20 17:04:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36469;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('335','07221', '150445', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-20 17:04:53', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36469-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 549680;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16279, '2024-12-20', 390.86161879896, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390.86161879896, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 390.86161879896, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390.86161879896, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '57', userid = '75', storedetaildate = '2024-12-20 17:04:53' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '58', '57', '75', '2024-12-20 17:04:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34599;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('130','06878', '150445', '5', '15690', '1', '145', '145', '0', '', '1', '2024-12-20 17:04:53', '15690', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34599-1,','1','1','0','0','145','145','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 130.00 , meanbuyprice = 130.00, lastbuyprice_withDiscount = 130.00, meanbuyprice_withDiscount = 130.00
        , lastbuyprice_withTax = 130, meanbuyprice_withTax = 130, lastbuyprice_withDiscountAndTax = 130
                where sellbilldetailid = 549681;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15690, '2024-12-20', 141.68733681462, 130, 130
                    , 130, 130, 130, 130
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 130, 130, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+141.68733681462, sellCostBuyPrice =sellCostBuyPrice+130
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+130, sellCostMeanBuyPrice = sellCostMeanBuyPrice+130
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+130, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+130
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+130
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+130
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+130
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 141.68733681462, 130, 130
                    , 130, 130, 130, 130
                    , 0, 0, 0, 0
                    , 0, 0, 0, 130, 130, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+141.68733681462, sellCostBuyPrice =sellCostBuyPrice+130
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+130, sellCostMeanBuyPrice = sellCostMeanBuyPrice+130
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+130, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+130
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+130
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+130
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+130
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 17:04:53' WHERE storedetailid = '15689';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15690', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-20 17:04:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 29886;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('400','66576', '150445', '5', '13384', '2', '190', '380', '0', '', '1', '2024-12-20 17:04:54', '13384', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29886-2,','1','1','0','0','190','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
        
                where sellbilldetailid = 549682;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13384, '2024-12-20', 371.31853785901, 820, 820
                    , 820, 820, 820, 810
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+371.31853785901, sellCostBuyPrice =sellCostBuyPrice+820
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+820, sellCostMeanBuyPrice = sellCostMeanBuyPrice+820
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+820, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+820
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+810
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 371.31853785901, 820, 820
                    , 820, 820, 820, 810
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+371.31853785901, sellCostBuyPrice =sellCostBuyPrice+820
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+820, sellCostMeanBuyPrice = sellCostMeanBuyPrice+820
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+820, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+820
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+810
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 17:04:54' WHERE storedetailid = '13383';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13384', '1', '2', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '3', '75', '2024-12-20 17:04:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34769;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('235','06924', '150445', '5', '15783', '1', '300', '300', '0', '', '1', '2024-12-20 17:04:54', '15783', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34769-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 235.00
        , lastbuyprice_withTax = 235, meanbuyprice_withTax = 235, lastbuyprice_withDiscountAndTax = 235
                where sellbilldetailid = 549683;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15783, '2024-12-20', 293.14621409922, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+293.14621409922, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+235
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 293.14621409922, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+293.14621409922, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+235
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 17:04:54' WHERE storedetailid = '15782';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15783', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-20 17:04:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36197;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('300','H1652', '150445', '14', '16407', '1', '380', '380', '0', '', '1', '2024-12-20 17:04:54', '16407', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36197-1,','1','1','0','0','380','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 300, lastbuyprice_withDiscountAndTax = 300
                where sellbilldetailid = 549684;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16407, '2024-12-20', 371.31853785901, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+371.31853785901, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+300
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 371.31853785901, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+371.31853785901, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+300
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '75', storedetaildate = '2024-12-20 17:04:54' WHERE storedetailid = '16406';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16407', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-20 17:04:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35802;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('190','06951', '150445', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-20 17:04:54', '15850', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35802-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 188, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 549685;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15850, '2024-12-20', 234.51697127937, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 190, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+234.51697127937, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+188
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 234.51697127937, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+234.51697127937, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+188
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '40', userid = '75', storedetaildate = '2024-12-20 17:04:54' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41', '40', '75', '2024-12-20 17:04:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30810;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('280','06127', '150445', '5', '13868', '1', '240', '240', '0', '', '1', '2024-12-20 17:04:54', '13868', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30810-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        
                where sellbilldetailid = 549686;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13868, '2024-12-20', 234.51697127937, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+234.51697127937, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 234.51697127937, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+234.51697127937, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '75', storedetaildate = '2024-12-20 17:04:54' WHERE storedetailid = '13867';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13868', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-20 17:04:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36335;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('180','H1658', '150445', '14', '16424', '1', '250', '250', '0', '', '1', '2024-12-20 17:04:54', '16424', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36335-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
        , lastbuyprice_withTax = 180, meanbuyprice_withTax = 180, lastbuyprice_withDiscountAndTax = 180
                where sellbilldetailid = 549687;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16424, '2024-12-20', 244.28851174935, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+244.28851174935, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+180
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 244.28851174935, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+244.28851174935, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+180
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '75', storedetaildate = '2024-12-20 17:04:54' WHERE storedetailid = '16423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16424', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-20 17:04:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31745;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','R2818', '150445', '1', '14049', '1', '145', '145', '0', '', '1', '2024-12-20 17:04:54', '14049', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31745-1,','1','1','0','0','145','145','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 557.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 557.00
        
                where sellbilldetailid = 549688;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14049, '2024-12-20', 141.68733681462, 240, 240
                    , 557, 240, 557, 237.22
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+141.68733681462, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+557
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+557
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.22
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 141.68733681462, 240, 240
                    , 557, 240, 557, 237.22
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+141.68733681462, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+557
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+557
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.22
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 17:04:54' WHERE storedetailid = '14048';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14049', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 17:04:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31268;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','06177', '150445', '5', '14074', '1', '210', '210', '0', '', '1', '2024-12-20 17:04:54', '14074', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31268-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        
                where sellbilldetailid = 549689;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14074, '2024-12-20', 205.20234986945, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205.20234986945, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 205.20234986945, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205.20234986945, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 17:04:54' WHERE storedetailid = '14073';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14074', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-20 17:04:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35070;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','06929', '150445', '5', '15805', '1', '220', '220', '0', '', '1', '2024-12-20 17:04:54', '15805', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35070-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 549690;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15805, '2024-12-20', 214.97389033943, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+214.97389033943, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 214.97389033943, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+214.97389033943, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '75', storedetaildate = '2024-12-20 17:04:54' WHERE storedetailid = '15804';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15805', '1', '1', '1', '150445', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-20 17:04:54','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150445', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 17:04:54', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150445', '17', '10291', '1', '46', '46', '0', '', '1', '2024-12-20 17:04:54', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','46','46','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 91 where clientid = 1798;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 4491, 5280, 5280
                    , 6523, 5280, 6523, 5264.72
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2495, 2424, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4491, sellCostBuyPrice =sellCostBuyPrice+5280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+5280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6523
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+5280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6523
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+5264.72
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2424
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1798, '2024-12-20', 4491, 5280, 5280
                    , 6523, 5280, 6523, 5264.72
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2495, 2424, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4491, sellCostBuyPrice =sellCostBuyPrice+5280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+5280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6523
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+5280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6523
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+5264.72
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2424
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 4491, 5280, 5280
                    , 6523, 5280, 6523, 5264.72, 2495, 2424)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+4491, netSellCostBuyPrice = netSellCostBuyPrice+5280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+5280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+6523
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+5280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+6523
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+5264.72
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2495
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2424;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676584f821378 and sellbillId = 150445 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:34:55";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:04:55", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:04:55', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:34:56";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:04:56", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:04:56', '101', 'editprint', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150431');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:35:13";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:05:13", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:05:13', '75', 'showDetail', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150445');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:35:17";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:05:17", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:05:17', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('067658792cec52', '2024-12-20 17:04:50', '78', '333150.00', '322725', '0', '0', '-10425', '-10425', '0', '-10425', '1', '2024-12-20 17:05:17', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07318', '2529', '5', '16488', '15', '455', '6825', '0', '', '16488','','','0','0','0','0','0','455','6825','0','0','0','0','0','0','0');
UPDATE product SET productName = '7318', productDescription = '', productCatId = '5', productBuyPrice = '455.00', productSellAllPrice = '530.00', productSellUnitPrice = '530.00', productSellHalfPrice = '530.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07318',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '455',lastbuyprice_withDiscount = '455',meanbuyprice = '455.00',meanbuyprice_withDiscount = '455' , productbuypricereal = '455.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='455',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='455',meanbuyprice_withTax='0',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='455'  WHERE productId = '16488';
UPDATE returnbuybilldetail SET  lastbuyprice = 455 , meanbuyprice = 455.00, lastbuyprice_withDiscount = 455, meanbuyprice_withDiscount = 455.00
        , lastbuyprice_withTax = 455, lastbuyprice_withDiscountAndTax = 455
                where returnbuybilldetailid = 3964;
UPDATE productunit SET proUnitBuyPrice  = 455 * productnumber WHERE productid = 16488;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16487';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16488', '1', '15', '1', '2529', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '15', '0', '77', '2024-12-20 17:04:50','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07320', '2529', '5', '16489', '15', '240', '3600', '0', '', '16489','','','0','0','0','0','0','240','3600','0','0','0','0','0','0','0');
UPDATE product SET productName = '7320', productDescription = '', productCatId = '5', productBuyPrice = '240.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07320',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '240',lastbuyprice_withDiscount = '240',meanbuyprice = '240.00',meanbuyprice_withDiscount = '240' , productbuypricereal = '240.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='240',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='240',meanbuyprice_withTax='0',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='240'  WHERE productId = '16489';
UPDATE returnbuybilldetail SET  lastbuyprice = 240 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where returnbuybilldetailid = 3965;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16489;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16488';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16489', '1', '15', '1', '2529', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '15', '0', '77', '2024-12-20 17:04:50','0','0');
UPDATE supplier SET  suppliercurrentDebt = '322725',suppliercurrentDebtInCurrency= '322725' , userid = '77', supplierdate = '2024-12-20 17:05:17'   WHERE supplierid = '78';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('78', '333150.00', '10425', '1', 'اضافة فاتورة مردوات مشتريات', '2529', '322725', '2024-12-20 17:04:50', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','10425','1','333150','10425','322725','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2529;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:35:18";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:05:18", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 17:05:18', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2529');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:35:23";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:05:23", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:05:23', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:35:24";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:05:24", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:05:24', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:35:45";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:05:45", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:05:45', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:35:50";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:05:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:05:50', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('0676587b4d2579', '2024-12-20 17:05:24', '101', '152310.00', '142610', '0', '0', '-9700', '-9700', '0', '-9700', '1', '2024-12-20 17:05:50', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07037', '2530', '5', '15995', '10', '420', '4200', '0', '', '15995','','','0','0','0','0','0','420','4200','0','0','0','0','0','0','0');
UPDATE product SET productName = '7037', productDescription = '', productCatId = '5', productBuyPrice = '420.00', productSellAllPrice = '480.00', productSellUnitPrice = '480.00', productSellHalfPrice = '480.00', productDate = '2024-11-16', conditions = '0', userId = '77', limitamount = '1', parcode = '07037',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '420',lastbuyprice_withDiscount = '420',meanbuyprice = '420',meanbuyprice_withDiscount = '420' , productbuypricereal = '420.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='420',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='420',meanbuyprice_withTax='420',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='420'  WHERE productId = '15995';
UPDATE returnbuybilldetail SET  lastbuyprice = 420 , meanbuyprice = 420, lastbuyprice_withDiscount = 420, meanbuyprice_withDiscount = 420
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where returnbuybilldetailid = 3966;
UPDATE productunit SET proUnitBuyPrice  = 420 * productnumber WHERE productid = 15995;
UPDATE storedetail SET  productquantity = '41', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '10', '1', '2530', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '51', '41', '77', '2024-12-20 17:05:24','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07257', '2530', '5', '16373', '10', '550', '5500', '0', '', '16373','','','0','0','0','0','0','550','5500','0','0','0','0','0','0','0');
UPDATE product SET productName = '7257', productDescription = '', productCatId = '5', productBuyPrice = '550.00', productSellAllPrice = '620.00', productSellUnitPrice = '620.00', productSellHalfPrice = '620.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07257',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '550',lastbuyprice_withDiscount = '550',meanbuyprice = '550',meanbuyprice_withDiscount = '550' , productbuypricereal = '550.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='550',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='550',meanbuyprice_withTax='550',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='550'  WHERE productId = '16373';
UPDATE returnbuybilldetail SET  lastbuyprice = 550 , meanbuyprice = 550, lastbuyprice_withDiscount = 550, meanbuyprice_withDiscount = 550
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 550, lastbuyprice_withDiscountAndTax = 550
                where returnbuybilldetailid = 3967;
UPDATE productunit SET proUnitBuyPrice  = 550 * productnumber WHERE productid = 16373;
UPDATE storedetail SET  productquantity = '21', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16372';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16373', '1', '10', '1', '2530', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '31', '21', '77', '2024-12-20 17:05:24','0','0');
UPDATE supplier SET  suppliercurrentDebt = '142610',suppliercurrentDebtInCurrency= '142610' , userid = '77', supplierdate = '2024-12-20 17:05:50'   WHERE supplierid = '101';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('101', '152310.00', '9700', '1', 'اضافة فاتورة مردوات مشتريات', '2530', '142610', '2024-12-20 17:05:24', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','9700','1','152310','9700','142610','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2530;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:35:51";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:05:51", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 17:05:51', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2530');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:35:52";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:05:52", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:05:52', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:35:56";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:05:56", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:05:56', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:36:01";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:06:01", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:06:01', '101', 'editsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150209');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:36:24";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:06:24", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:06:24', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('0676587d4ee752', '2024-12-20 17:05:56', '19', '264430.00', '260230', '0', '0', '-4200', '-4200', '0', '-4200', '1', '2024-12-20 17:06:24', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07037', '2531', '5', '15995', '10', '420', '4200', '0', '', '15995','','','0','0','0','0','0','420','4200','0','0','0','0','0','0','0');
UPDATE product SET productName = '7037', productDescription = '', productCatId = '5', productBuyPrice = '420.00', productSellAllPrice = '480.00', productSellUnitPrice = '480.00', productSellHalfPrice = '480.00', productDate = '2024-11-16', conditions = '0', userId = '77', limitamount = '1', parcode = '07037',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '420',lastbuyprice_withDiscount = '420',meanbuyprice = '420',meanbuyprice_withDiscount = '420' , productbuypricereal = '420.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='420',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='420',meanbuyprice_withTax='420',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='420'  WHERE productId = '15995';
UPDATE returnbuybilldetail SET  lastbuyprice = 420 , meanbuyprice = 420, lastbuyprice_withDiscount = 420, meanbuyprice_withDiscount = 420
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where returnbuybilldetailid = 3968;
UPDATE productunit SET proUnitBuyPrice  = 420 * productnumber WHERE productid = 15995;
UPDATE storedetail SET  productquantity = '31', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '10', '1', '2531', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '41', '31', '77', '2024-12-20 17:05:56','0','0');
UPDATE supplier SET  suppliercurrentDebt = '260230',suppliercurrentDebtInCurrency= '260230' , userid = '77', supplierdate = '2024-12-20 17:06:24'   WHERE supplierid = '19';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('19', '264430.00', '4200', '1', 'اضافة فاتورة مردوات مشتريات', '2531', '260230', '2024-12-20 17:05:56', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','4200','1','264430','4200','260230','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2531;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:36:24";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:06:24", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 17:06:24', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2531');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:36:27";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:06:27", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:06:27', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:36:39";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:06:39", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:06:39', '101', 'update', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 150209 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 150209 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150209;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 17:06:39', userid = '75',delbyuserid = '101', conditions = '1'  WHERE sellbillid = '150209';
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        
                where sellbilldetailid = 548764;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15465, '2024-12-20', 390, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-390, sellCostBuyPrice =sellCostBuyPrice-300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-300, sellCostMeanBuyPrice = sellCostMeanBuyPrice-300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 390, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-390, sellCostBuyPrice =sellCostBuyPrice-300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-300, sellCostMeanBuyPrice = sellCostMeanBuyPrice-300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 17:06:39' WHERE storedetailid = '15464';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15465', '1', '1', '0', '150209', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '101', '2024-12-19 14:19:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 29616;
UPDATE sellbilldetail SET  lastbuyprice = 440.00 , meanbuyprice = 1133.00, lastbuyprice_withDiscount = 440.00, meanbuyprice_withDiscount = 1133.00
        
                where sellbilldetailid = 548765;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13053, '2024-12-20', 355, 440, 440
                    , 1133, 440, 1133, 439.17
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-355, sellCostBuyPrice =sellCostBuyPrice-440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-440, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1133
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1133
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-439.17
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 355, 440, 440
                    , 1133, 440, 1133, 439.17
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-355, sellCostBuyPrice =sellCostBuyPrice-440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-440, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1133
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1133
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-439.17
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 17:06:39' WHERE storedetailid = '13052';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13053', '1', '1', '0', '150209', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '101', '2024-12-19 14:19:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35278;
UPDATE sellbilldetail SET  lastbuyprice = 390.00 , meanbuyprice = 390.00, lastbuyprice_withDiscount = 390.00, meanbuyprice_withDiscount = 390.00
        , lastbuyprice_withTax = 390, meanbuyprice_withTax = 390, lastbuyprice_withDiscountAndTax = 390
                where sellbilldetailid = 548766;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15769, '2024-12-20', 460, 390, 390
                    , 390, 390, 390, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 390, 390, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-460, sellCostBuyPrice =sellCostBuyPrice-390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-390, sellCostMeanBuyPrice = sellCostMeanBuyPrice-390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-390
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-390
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-390
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-390
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 460, 390, 390
                    , 390, 390, 390, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0, 390, 390, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-460, sellCostBuyPrice =sellCostBuyPrice-390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-390, sellCostMeanBuyPrice = sellCostMeanBuyPrice-390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-390
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-390
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-390
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-390
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '16', userid = '101', storedetaildate = '2024-12-20 17:06:39' WHERE storedetailid = '15768';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15769', '1', '1', '0', '150209', 'تعديل فاتورة مبيعات', 'sellbillController.php', '15', '16', '101', '2024-12-19 14:19:14','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 630.00 , meanbuyprice = 630.00, lastbuyprice_withDiscount = 630.00, meanbuyprice_withDiscount = 630.00
        , lastbuyprice_withTax = 630, meanbuyprice_withTax = 630, lastbuyprice_withDiscountAndTax = 630
                where sellbilldetailid = 548767;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16227, '2024-12-20', 750, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-750, sellCostBuyPrice =sellCostBuyPrice-630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-630, sellCostMeanBuyPrice = sellCostMeanBuyPrice-630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-630
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 750, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-750, sellCostBuyPrice =sellCostBuyPrice-630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-630, sellCostMeanBuyPrice = sellCostMeanBuyPrice-630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-630
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 17:06:39' WHERE storedetailid = '16226';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16227', '1', '1', '0', '150209', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '101', '2024-12-19 14:19:14','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 412.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 412.00
        
                where sellbilldetailid = 548768;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9356, '2024-12-20', 505, 415, 410
                    , 412, 410, 412, 411.79
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-505, sellCostBuyPrice =sellCostBuyPrice-415
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-410, sellCostMeanBuyPrice = sellCostMeanBuyPrice-412
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-412
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-411.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 505, 415, 410
                    , 412, 410, 412, 411.79
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-505, sellCostBuyPrice =sellCostBuyPrice-415
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-410, sellCostMeanBuyPrice = sellCostMeanBuyPrice-412
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-412
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-411.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-20 17:06:40' WHERE storedetailid = '9355';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9356', '1', '1', '0', '150209', 'تعديل فاتورة مبيعات', 'sellbillController.php', '3', '4', '101', '2024-12-19 14:19:14','0','0');
CALL clientInUse(10754,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '101' WHERE clientid = '10754';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10754','2505.00','2505.00','1','تعديل فاتورة مبيعات','150209', '0', '2024-12-19 14:19:14', '101', 'sellbillController.php', 'تعديل فاتورة مبيعات', '2505', '0', null, '0', null, null,'', '0','1','1','2505','1','2024-12-19 14:19:14','0','0');
UPDATE client SET  inUse = 0 where clientid = 10754;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2505, 2175, 2170
                    , 2865, 2170, 2865, 1870.96
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1020, 1020, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-2505, sellCostBuyPrice =sellCostBuyPrice-2175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-2170, sellCostMeanBuyPrice = sellCostMeanBuyPrice-2865
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-2170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-2865
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1870.96
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1020
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1020
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10754, '2024-12-20', 2505, 2175, 2170
                    , 2865, 2170, 2865, 1870.96
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1020, 1020, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-2505, sellCostBuyPrice =sellCostBuyPrice-2175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-2170, sellCostMeanBuyPrice = sellCostMeanBuyPrice-2865
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-2170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-2865
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1870.96
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1020
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1020
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2505, 2175, 2170
                    , 2865, 2170, 2865, 1870.96, 1020, 1020)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-2505, netSellCostBuyPrice = netSellCostBuyPrice-2175
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-2170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-2865
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-2170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-2865
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-1870.96
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-1020
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-1020;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 150209 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 150209 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(10754,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-19 14:19:14', '067640f427a281', '10754', '0.00', '2121', '25', '1', '2146', '2121', '0', '2121', '1', '2024-12-19 14:19:14', '', '101', '0', 'شيماء عيد 12', '2', '1', '3', '81', 'شيماء عيد 12', '6', '150209', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-19','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2121', userid = '101' WHERE clientid = '10754';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10754','0.00','2121','0','اضافة فاتورة مبيعات (معدله)','150446', '2121', '2024-12-20 17:06:40', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '2121', '0', null, '0', null, null,'', '0','1','1','2505','1','2024-12-19 14:19:14','0','0');
UPDATE client SET  inUse = 0 where clientid = 10754;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('300','H1353', '150446', '14', '15465', '1', '390', '390', '0', '', '1', '2024-12-20 17:06:40', '15465', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','390','390','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        
                where sellbilldetailid = 549693;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15465, '2024-12-20', 385.45666356011, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+385.45666356011, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 385.45666356011, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+385.45666356011, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '101', storedetaildate = '2024-12-20 17:06:40' WHERE storedetailid = '15464';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15465', '1', '1', '1', '150446', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '1', '0', '101', '2024-12-20 17:06:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35278;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('390','H1436', '150446', '14', '15769', '1', '460', '460', '0', '', '1', '2024-12-20 17:06:40', '15769', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35278-1,','1','1','0','0','460','460','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 390.00 , meanbuyprice = 390.00, lastbuyprice_withDiscount = 390.00, meanbuyprice_withDiscount = 390.00
        , lastbuyprice_withTax = 390, meanbuyprice_withTax = 390, lastbuyprice_withDiscountAndTax = 390
                where sellbilldetailid = 549694;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15769, '2024-12-20', 454.64119291705, 390, 390
                    , 390, 390, 390, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 390, 390, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+454.64119291705, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+390
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+390
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+390
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 454.64119291705, 390, 390
                    , 390, 390, 390, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0, 390, 390, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+454.64119291705, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+390
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+390
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+390
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '101', storedetaildate = '2024-12-20 17:06:40' WHERE storedetailid = '15768';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15769', '1', '1', '1', '150446', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '16', '15', '101', '2024-12-20 17:06:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('630','H1593', '150446', '14', '16227', '1', '750', '750', '0', '', '1', '2024-12-20 17:06:40', '16227', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','750','750','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 630.00 , meanbuyprice = 630.00, lastbuyprice_withDiscount = 630.00, meanbuyprice_withDiscount = 630.00
        , lastbuyprice_withTax = 630, meanbuyprice_withTax = 630, lastbuyprice_withDiscountAndTax = 630
                where sellbilldetailid = 549695;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16227, '2024-12-20', 741.26281453868, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+741.26281453868, sellCostBuyPrice =sellCostBuyPrice+630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+630
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 741.26281453868, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+741.26281453868, sellCostBuyPrice =sellCostBuyPrice+630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+630
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '101', storedetaildate = '2024-12-20 17:06:40' WHERE storedetailid = '16226';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16227', '1', '1', '1', '150446', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '1', '0', '101', '2024-12-20 17:06:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('415','H1018', '150446', '14', '9356', '1', '505', '505', '0', '', '1', '2024-12-20 17:06:40', '9356', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','505','505','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 412.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 412.00
        
                where sellbilldetailid = 549696;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9356, '2024-12-20', 499.11696178938, 415, 410
                    , 412, 410, 412, 411.79
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+499.11696178938, sellCostBuyPrice =sellCostBuyPrice+415
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+412
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+412
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+411.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 499.11696178938, 415, 410
                    , 412, 410, 412, 411.79
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+499.11696178938, sellCostBuyPrice =sellCostBuyPrice+415
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+412
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+412
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+411.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '101', storedetaildate = '2024-12-20 17:06:40' WHERE storedetailid = '9355';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9356', '1', '1', '1', '150446', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '4', '3', '101', '2024-12-20 17:06:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150446', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 17:06:40', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150446', '17', '10291', '1', '21', '21', '0', '', '1', '2024-12-20 17:06:40', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','21','21','0','','0','0.00','0','0','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2121, 1735, 1730
                    , 1732, 1730, 1732, 1431.79
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1020, 1020, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2121, sellCostBuyPrice =sellCostBuyPrice+1735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1730, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1732
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1730, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1732
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1431.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1020
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1020
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10754, '2024-12-20', 2121, 1735, 1730
                    , 1732, 1730, 1732, 1431.79
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1020, 1020, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2121, sellCostBuyPrice =sellCostBuyPrice+1735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1730, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1732
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1730, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1732
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1431.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1020
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1020
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2121, 1735, 1730
                    , 1732, 1730, 1732, 1431.79, 1020, 1020)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2121, netSellCostBuyPrice = netSellCostBuyPrice+1735
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1730
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1732
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1730
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1732
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1431.79
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1020
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1020;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150209 and newid=150446 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:36:40";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:06:40", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:06:40', '101', 'editprint', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150446');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:37:01";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:07:01", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:07:01', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('0676587f3be886', '2024-12-20 17:06:27', '6', '320230.00', '307180', '0', '0', '-13050', '-13050', '0', '-13050', '1', '2024-12-20 17:07:02', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('R3328', '2532', '1', '16325', '15', '380', '5700', '0', '', '16325','','','0','0','0','0','0','380','5700','0','0','0','0','0','0','0');
UPDATE product SET productName = 'R3328', productDescription = '', productCatId = '1', productBuyPrice = '380.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2024-12-07', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3328',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '380',lastbuyprice_withDiscount = '380',meanbuyprice = '380',meanbuyprice_withDiscount = '380' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='380',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='380',meanbuyprice_withTax='380',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='380'  WHERE productId = '16325';
UPDATE returnbuybilldetail SET  lastbuyprice = 380 , meanbuyprice = 380, lastbuyprice_withDiscount = 380, meanbuyprice_withDiscount = 380
        , lastbuyprice_withTax = 380, meanbuyprice_withTax = 380, lastbuyprice_withDiscountAndTax = 380
                where returnbuybilldetailid = 3969;
UPDATE productunit SET proUnitBuyPrice  = 380 * productnumber WHERE productid = 16325;
UPDATE storedetail SET  productquantity = '13', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16324';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16325', '1', '15', '1', '2532', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '28', '13', '77', '2024-12-20 17:06:27','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('H1664', '2532', '14', '16445', '15', '490', '7350', '0', '', '16445','','','0','0','0','0','0','490','7350','0','0','0','0','0','0','0');
UPDATE product SET productName = 'H1664', productDescription = '', productCatId = '14', productBuyPrice = '490.00', productSellAllPrice = '650.00', productSellUnitPrice = '650.00', productSellHalfPrice = '650.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1664',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '490',lastbuyprice_withDiscount = '490',meanbuyprice = '490',meanbuyprice_withDiscount = '490' , productbuypricereal = '490.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='490',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='490',meanbuyprice_withTax='490',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='490'  WHERE productId = '16445';
UPDATE returnbuybilldetail SET  lastbuyprice = 490 , meanbuyprice = 490, lastbuyprice_withDiscount = 490, meanbuyprice_withDiscount = 490
        , lastbuyprice_withTax = 490, meanbuyprice_withTax = 490, lastbuyprice_withDiscountAndTax = 490
                where returnbuybilldetailid = 3970;
UPDATE productunit SET proUnitBuyPrice  = 490 * productnumber WHERE productid = 16445;
UPDATE storedetail SET  productquantity = '5', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16444';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16445', '1', '15', '1', '2532', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '20', '5', '77', '2024-12-20 17:06:27','0','0');
UPDATE supplier SET  suppliercurrentDebt = '307180',suppliercurrentDebtInCurrency= '307180' , userid = '77', supplierdate = '2024-12-20 17:07:02'   WHERE supplierid = '6';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('6', '320230.00', '13050', '1', 'اضافة فاتورة مردوات مشتريات', '2532', '307180', '2024-12-20 17:06:27', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','13050','1','320230','13050','307180','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2532;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:37:02";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:07:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 17:07:02', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2532');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:37:10";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:07:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:07:10', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:37:15";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:07:15", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:07:15', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:37:22";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:07:22", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:07:22', '101', 'editsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=149985');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:37:27";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:07:27", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:07:27', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('06765881e2e8aa', '2024-12-20 17:07:10', '9', '311750.00', '299750', '0', '0', '-12000', '-12000', '0', '-12000', '1', '2024-12-20 17:07:27', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('H1662', '2533', '14', '16429', '20', '600', '12000', '0', '', '16429','','','0','0','0','0','0','600','12000','0','0','0','0','0','0','0');
UPDATE product SET productName = 'H1662', productDescription = '', productCatId = '14', productBuyPrice = '600.00', productSellAllPrice = '750.00', productSellUnitPrice = '750.00', productSellHalfPrice = '750.00', productDate = '2024-12-13', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1662',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '600',lastbuyprice_withDiscount = '600',meanbuyprice = '600.00',meanbuyprice_withDiscount = '600' , productbuypricereal = '600.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='600',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='600',meanbuyprice_withTax='0',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='600'  WHERE productId = '16429';
UPDATE returnbuybilldetail SET  lastbuyprice = 600 , meanbuyprice = 600.00, lastbuyprice_withDiscount = 600, meanbuyprice_withDiscount = 600.00
        , lastbuyprice_withTax = 600, lastbuyprice_withDiscountAndTax = 600
                where returnbuybilldetailid = 3971;
UPDATE productunit SET proUnitBuyPrice  = 600 * productnumber WHERE productid = 16429;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16428';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16429', '1', '20', '1', '2533', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '20', '0', '77', '2024-12-20 17:07:10','0','0');
UPDATE supplier SET  suppliercurrentDebt = '299750',suppliercurrentDebtInCurrency= '299750' , userid = '77', supplierdate = '2024-12-20 17:07:27'   WHERE supplierid = '9';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('9', '311750.00', '12000', '1', 'اضافة فاتورة مردوات مشتريات', '2533', '299750', '2024-12-20 17:07:10', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','12000','1','311750','12000','299750','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2533;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:37:27";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:07:27", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 17:07:27', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2533');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:37:48";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:07:48", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:07:48', '101', 'update', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 149985 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 149985 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149985;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 17:07:48', userid = '75',delbyuserid = '101', conditions = '1'  WHERE sellbillid = '149985';
UPDATE sellbilldetail SET  lastbuyprice = 110.00 , meanbuyprice = 113.00, lastbuyprice_withDiscount = 110.00, meanbuyprice_withDiscount = 113.00
        
                where sellbilldetailid = 547898;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14756, '2024-12-20', 130, 110, 110
                    , 113, 110, 113, 113.33
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-130, sellCostBuyPrice =sellCostBuyPrice-110
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-110, sellCostMeanBuyPrice = sellCostMeanBuyPrice-113
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-110, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-113
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-113.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 130, 110, 110
                    , 113, 110, 113, 113.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-130, sellCostBuyPrice =sellCostBuyPrice-110
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-110, sellCostMeanBuyPrice = sellCostMeanBuyPrice-113
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-110, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-113
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-113.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '3', userid = '101', storedetaildate = '2024-12-20 17:07:48' WHERE storedetailid = '14755';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14756', '1', '1', '0', '149985', 'تعديل فاتورة مبيعات', 'sellbillController.php', '2', '3', '101', '2024-12-18 11:37:17','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
        
                where sellbilldetailid = 547899;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14647, '2024-12-20', 185, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-185, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 185, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-185, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 17:07:48' WHERE storedetailid = '14646';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14647', '1', '1', '0', '149985', 'تعديل فاتورة مبيعات', 'sellbillController.php', '1', '2', '101', '2024-12-18 11:37:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 32630;
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        
                where sellbilldetailid = 547900;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14701, '2024-12-20', 205, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-205, sellCostBuyPrice =sellCostBuyPrice-190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-190, sellCostMeanBuyPrice = sellCostMeanBuyPrice-190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 205, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-205, sellCostBuyPrice =sellCostBuyPrice-190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-190, sellCostMeanBuyPrice = sellCostMeanBuyPrice-190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '22', userid = '101', storedetaildate = '2024-12-20 17:07:48' WHERE storedetailid = '14700';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14701', '1', '1', '0', '149985', 'تعديل فاتورة مبيعات', 'sellbillController.php', '21', '22', '101', '2024-12-18 11:37:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 30778;
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 547901;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13859, '2024-12-20', 145, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-145, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 145, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-145, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-20 17:07:48' WHERE storedetailid = '13858';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13859', '1', '1', '0', '149985', 'تعديل فاتورة مبيعات', 'sellbillController.php', '3', '4', '101', '2024-12-18 11:37:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 31746;
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 249.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 249.00
        
                where sellbilldetailid = 547902;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14267, '2024-12-20', 200, 245, 240
                    , 249, 240, 249, 248.57
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-200, sellCostBuyPrice =sellCostBuyPrice-245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-240, sellCostMeanBuyPrice = sellCostMeanBuyPrice-249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-248.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 245, 240
                    , 249, 240, 249, 248.57
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-200, sellCostBuyPrice =sellCostBuyPrice-245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-240, sellCostMeanBuyPrice = sellCostMeanBuyPrice-249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-248.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 17:07:48' WHERE storedetailid = '14266';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14267', '1', '1', '0', '149985', 'تعديل فاتورة مبيعات', 'sellbillController.php', '1', '2', '101', '2024-12-18 11:37:17','0','0');
CALL clientInUse(10738,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '101' WHERE clientid = '10738';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10738','894.00','894.00','1','تعديل فاتورة مبيعات','149985', '0', '2024-12-18 11:37:17', '101', 'sellbillController.php', 'تعديل فاتورة مبيعات', '894', '0', null, '0', null, null,'', '0','1','1','894','1','2024-12-18 11:37:17','0','0');
UPDATE client SET  inUse = 0 where clientid = 10738;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 894, 1015, 1010
                    , 1022, 1010, 1022, 1021.9
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-894, sellCostBuyPrice =sellCostBuyPrice-1015
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1010, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1022
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1010, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1022
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1021.9
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10738, '2024-12-20', 894, 1015, 1010
                    , 1022, 1010, 1022, 1021.9
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-894, sellCostBuyPrice =sellCostBuyPrice-1015
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1010, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1022
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1010, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1022
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1021.9
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 894, 1015, 1010
                    , 1022, 1010, 1022, 1021.9, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-894, netSellCostBuyPrice = netSellCostBuyPrice-1015
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-1010
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-1022
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-1010
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-1022
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-1021.9
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-0;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 149985 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 149985 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(10738,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-18 11:37:17', '0676297cda9b27', '10738', '0.00', '707', '0', '1', '707', '707', '0', '707', '1', '2024-12-18 11:37:17', '', '101', '0', 'اميرة البنا 33', '2', '1', '3', '89', 'اميرة البنا 33', '6', '149985', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-18','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '707', userid = '101' WHERE clientid = '10738';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10738','0.00','707','0','اضافة فاتورة مبيعات (معدله)','150447', '707', '2024-12-20 17:07:48', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '707', '0', null, '0', null, null,'', '0','1','1','894','1','2024-12-18 11:37:17','0','0');
UPDATE client SET  inUse = 0 where clientid = 10738;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33214;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('110','R3047', '150447', '1', '14756', '1', '130', '130', '0', '', '1', '2024-12-20 17:07:48', '14756', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33214-1,','1','1','0','0','130','130','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 110.00 , meanbuyprice = 113.00, lastbuyprice_withDiscount = 110.00, meanbuyprice_withDiscount = 113.00
        
                where sellbilldetailid = 549699;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14756, '2024-12-20', 130, 110, 110
                    , 113, 110, 113, 113.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+110
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+110, sellCostMeanBuyPrice = sellCostMeanBuyPrice+113
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+110, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+113
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+113.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 130, 110, 110
                    , 113, 110, 113, 113.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+110
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+110, sellCostMeanBuyPrice = sellCostMeanBuyPrice+113
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+110, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+113
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+113.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 17:07:49' WHERE storedetailid = '14755';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14756', '1', '1', '1', '150447', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '3', '2', '101', '2024-12-20 17:07:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32630;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('190','R3031', '150447', '1', '14701', '1', '205', '205', '0', '', '1', '2024-12-20 17:07:49', '14701', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32630-1,','1','1','0','0','205','205','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        
                where sellbilldetailid = 549700;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14701, '2024-12-20', 205, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 205, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '21', userid = '101', storedetaildate = '2024-12-20 17:07:49' WHERE storedetailid = '14700';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14701', '1', '1', '1', '150447', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '22', '21', '101', '2024-12-20 17:07:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30778;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','R2788', '150447', '1', '13859', '1', '145', '145', '0', '', '1', '2024-12-20 17:07:49', '13859', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30778-1,','1','1','0','0','145','145','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 549701;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13859, '2024-12-20', 145, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+145, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 145, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+145, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '101', storedetaildate = '2024-12-20 17:07:49' WHERE storedetailid = '13858';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13859', '1', '1', '1', '150447', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '4', '3', '101', '2024-12-20 17:07:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31746;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','R2864', '150447', '1', '14267', '1', '200', '200', '0', '', '1', '2024-12-20 17:07:49', '14267', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31746-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 249.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 249.00
        
                where sellbilldetailid = 549702;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14267, '2024-12-20', 200, 245, 240
                    , 249, 240, 249, 248.57
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+248.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 245, 240
                    , 249, 240, 249, 248.57
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+248.57
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 17:07:49' WHERE storedetailid = '14266';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14267', '1', '1', '1', '150447', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '2', '1', '101', '2024-12-20 17:07:49','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150447', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 17:07:49', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150447', '17', '10291', '1', '7', '7', '0', '', '1', '2024-12-20 17:07:49', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','7','7','0','','0','0.00','0','0','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 707, 795, 790
                    , 802, 790, 802, 801.9
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+707, sellCostBuyPrice =sellCostBuyPrice+795
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+802
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+802
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+801.9
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10738, '2024-12-20', 707, 795, 790
                    , 802, 790, 802, 801.9
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+707, sellCostBuyPrice =sellCostBuyPrice+795
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+802
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+802
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+801.9
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 707, 795, 790
                    , 802, 790, 802, 801.9, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+707, netSellCostBuyPrice = netSellCostBuyPrice+795
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+790
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+802
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+790
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+802
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+801.9
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 149985 and newid=150447 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:37:49";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:07:49", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:07:49', '101', 'editprint', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150447');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:37:54";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:07:54", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:07:54', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:38:10";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:08:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:08:10', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('06765884b0efba', '2024-12-20 17:07:55', '102', '204360.00', '200760', '0', '0', '-3600', '-3600', '0', '-3600', '1', '2024-12-20 17:08:10', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07256', '2534', '5', '16331', '15', '240', '3600', '0', '', '16331','','','0','0','0','0','0','240','3600','0','0','0','0','0','0','0');
UPDATE product SET productName = '7256', productDescription = '', productCatId = '5', productBuyPrice = '240.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-12-07', conditions = '0', userId = '77', limitamount = '1', parcode = '07256',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '240',lastbuyprice_withDiscount = '240',meanbuyprice = '240',meanbuyprice_withDiscount = '240' , productbuypricereal = '240.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='240',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='240',meanbuyprice_withTax='240',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='240'  WHERE productId = '16331';
UPDATE returnbuybilldetail SET  lastbuyprice = 240 , meanbuyprice = 240, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 240
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where returnbuybilldetailid = 3972;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16331;
UPDATE storedetail SET  productquantity = '37', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16330';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16331', '1', '15', '1', '2534', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '52', '37', '77', '2024-12-20 17:07:55','0','0');
UPDATE supplier SET  suppliercurrentDebt = '200760',suppliercurrentDebtInCurrency= '200760' , userid = '77', supplierdate = '2024-12-20 17:08:10'   WHERE supplierid = '102';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('102', '204360.00', '3600', '1', 'اضافة فاتورة مردوات مشتريات', '2534', '200760', '2024-12-20 17:07:55', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','3600','1','204360','3600','200760','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2534;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:38:10";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:08:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 17:08:10', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2534');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:38:37";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:08:37", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:08:37', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:38:44";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 17:08:44", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:08:44', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150444');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:39:02";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:09:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:09:02', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('067658875eed83', '2024-12-20 17:08:37', '7', '257040.00', '250440', '0', '0', '-6600', '-6600', '0', '-6600', '1', '2024-12-20 17:09:02', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('H1623', '2535', '14', '16312', '15', '440', '6600', '0', '', '16312','','','0','0','0','0','0','440','6600','0','0','0','0','0','0','0');
UPDATE product SET productName = 'H1623', productDescription = '', productCatId = '14', productBuyPrice = '440.00', productSellAllPrice = '530.00', productSellUnitPrice = '530.00', productSellHalfPrice = '530.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1623',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '440',lastbuyprice_withDiscount = '440',meanbuyprice = '440',meanbuyprice_withDiscount = '440' , productbuypricereal = '440.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='440',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='440',meanbuyprice_withTax='440',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='440'  WHERE productId = '16312';
UPDATE returnbuybilldetail SET  lastbuyprice = 440 , meanbuyprice = 440, lastbuyprice_withDiscount = 440, meanbuyprice_withDiscount = 440
        , lastbuyprice_withTax = 440, meanbuyprice_withTax = 440, lastbuyprice_withDiscountAndTax = 440
                where returnbuybilldetailid = 3973;
UPDATE productunit SET proUnitBuyPrice  = 440 * productnumber WHERE productid = 16312;
UPDATE storedetail SET  productquantity = '1', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16311';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16312', '1', '15', '1', '2535', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '16', '1', '77', '2024-12-20 17:08:37','0','0');
UPDATE supplier SET  suppliercurrentDebt = '250440',suppliercurrentDebtInCurrency= '250440' , userid = '77', supplierdate = '2024-12-20 17:09:02'   WHERE supplierid = '7';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('7', '257040.00', '6600', '1', 'اضافة فاتورة مردوات مشتريات', '2535', '250440', '2024-12-20 17:08:37', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','6600','1','257040','6600','250440','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2535;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:39:02";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:09:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 17:09:02', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2535');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:39:10";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:09:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:09:10', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:39:45";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:09:45", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:09:45', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('067658896de3a8', '2024-12-20 17:09:10', '20', '361460.00', '344960', '0', '0', '-16500', '-16500', '0', '-16500', '1', '2024-12-20 17:09:45', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07245', '2536', '5', '16363', '20', '575', '11500', '0', '', '16363','','','0','0','0','0','0','575','11500','0','0','0','0','0','0','0');
UPDATE product SET productName = '7245', productDescription = '', productCatId = '5', productBuyPrice = '575.00', productSellAllPrice = '650.00', productSellUnitPrice = '650.00', productSellHalfPrice = '650.00', productDate = '2024-12-09', conditions = '0', userId = '77', limitamount = '1', parcode = '07245',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '575',lastbuyprice_withDiscount = '575',meanbuyprice = '575',meanbuyprice_withDiscount = '575' , productbuypricereal = '575.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='575',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='575',meanbuyprice_withTax='575',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='575'  WHERE productId = '16363';
UPDATE returnbuybilldetail SET  lastbuyprice = 575 , meanbuyprice = 575, lastbuyprice_withDiscount = 575, meanbuyprice_withDiscount = 575
        , lastbuyprice_withTax = 575, meanbuyprice_withTax = 575, lastbuyprice_withDiscountAndTax = 575
                where returnbuybilldetailid = 3974;
UPDATE productunit SET proUnitBuyPrice  = 575 * productnumber WHERE productid = 16363;
UPDATE storedetail SET  productquantity = '53', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16362';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16363', '1', '20', '1', '2536', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '73', '53', '77', '2024-12-20 17:09:10','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07273', '2536', '5', '16395', '10', '500', '5000', '0', '', '16395','','','0','0','0','0','0','500','5000','0','0','0','0','0','0','0');
UPDATE product SET productName = '7273', productDescription = '', productCatId = '5', productBuyPrice = '500.00', productSellAllPrice = '580.00', productSellUnitPrice = '580.00', productSellHalfPrice = '580.00', productDate = '2024-12-11', conditions = '0', userId = '77', limitamount = '1', parcode = '07273',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '500',lastbuyprice_withDiscount = '500',meanbuyprice = '498',meanbuyprice_withDiscount = '498' , productbuypricereal = '510.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='500',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='500',meanbuyprice_withTax='500',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='500'  WHERE productId = '16395';
UPDATE returnbuybilldetail SET  lastbuyprice = 500 , meanbuyprice = 498, lastbuyprice_withDiscount = 500, meanbuyprice_withDiscount = 498
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 500, lastbuyprice_withDiscountAndTax = 500
                where returnbuybilldetailid = 3975;
UPDATE productunit SET proUnitBuyPrice  = 500 * productnumber WHERE productid = 16395;
UPDATE storedetail SET  productquantity = '18', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16394';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16395', '1', '10', '1', '2536', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '28', '18', '77', '2024-12-20 17:09:10','0','0');
UPDATE supplier SET  suppliercurrentDebt = '344960',suppliercurrentDebtInCurrency= '344960' , userid = '77', supplierdate = '2024-12-20 17:09:45'   WHERE supplierid = '20';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('20', '361460.00', '16500', '1', 'اضافة فاتورة مردوات مشتريات', '2536', '344960', '2024-12-20 17:09:10', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','16500','1','361460','16500','344960','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2536;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:39:46";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:09:46", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 17:09:46', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2536');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:39:59";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:09:59", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:09:59', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:40:19";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:10:19", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:10:19', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('0676588c81e1c4', '2024-12-20 17:10:00', '27', '411400.00', '406000', '0', '0', '-5400', '-5400', '0', '-5400', '1', '2024-12-20 17:10:19', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07253', '2537', '5', '16370', '15', '360', '5400', '0', '', '16370','','','0','0','0','0','0','360','5400','0','0','0','0','0','0','0');
UPDATE product SET productName = '7253', productDescription = '', productCatId = '5', productBuyPrice = '360.00', productSellAllPrice = '420.00', productSellUnitPrice = '420.00', productSellHalfPrice = '420.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07253',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '360',lastbuyprice_withDiscount = '360',meanbuyprice = '360',meanbuyprice_withDiscount = '360' , productbuypricereal = '360.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='360',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='360',meanbuyprice_withTax='360',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='360'  WHERE productId = '16370';
UPDATE returnbuybilldetail SET  lastbuyprice = 360 , meanbuyprice = 360, lastbuyprice_withDiscount = 360, meanbuyprice_withDiscount = 360
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where returnbuybilldetailid = 3976;
UPDATE productunit SET proUnitBuyPrice  = 360 * productnumber WHERE productid = 16370;
UPDATE storedetail SET  productquantity = '12', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16369';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16370', '1', '15', '1', '2537', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '27', '12', '77', '2024-12-20 17:10:00','0','0');
UPDATE supplier SET  suppliercurrentDebt = '406000',suppliercurrentDebtInCurrency= '406000' , userid = '77', supplierdate = '2024-12-20 17:10:19'   WHERE supplierid = '27';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('27', '411400.00', '5400', '1', 'اضافة فاتورة مردوات مشتريات', '2537', '406000', '2024-12-20 17:10:00', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','5400','1','411400','5400','406000','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2537;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:40:20";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:10:20", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 17:10:20', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2537');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:40:36";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:10:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:10:36', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:40:50";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:10:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:10:50', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676588ecc6e2b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:10:36', '0676588ecc6e2b', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2024-12-20 17:10:50', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150448', '0', '2024-12-20 17:10:50', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 17:10:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35571;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','06934', '150448', '5', '15820', '1', '200', '200', '0', '', '1', '2024-12-20 17:10:50', '15820', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35571-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549705;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15820, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 141.11
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+141.11
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 141.11
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+141.11
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-20 17:10:50' WHERE storedetailid = '15819';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15820', '1', '1', '1', '150448', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-20 17:10:50','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6950',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6750','200', '0', '1', 'اضافة فاتورة مبيعات', '150448', '6950', '2024-12-20 17:10:50', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 200, 140, 140
                    , 140, 140, 140, 141.11
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+141.11
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 141.11
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+141.11
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 200, 140, 140
                    , 140, 140, 140, 141.11, 140, 140)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+140
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+140
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+140
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+140
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+140
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+141.11
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+140;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676588ecc6e2b and sellbillId = 150448 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:40:51";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:10:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:10:51', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:40:53";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:10:53", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:10:53', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:41:03";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:11:03", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:11:03', '77', 'details', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=details&id=14174');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:41:34";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:11:34", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:11:34', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:41:36";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:11:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:11:36', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:41:36";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:11:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:11:36', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:41:51";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:11:51", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:11:51', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7355','','5','160','220', '220','220', '2024-12-20', '0', '77', '1', '07355', '0', '0', '0', '0', '0', '160','160','160','160','160','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','160','160','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16533, 1,'2024-12-20 17:12:01',77)
                ON DUPLICATE KEY UPDATE productid = 16533, edited = 1, sysdate = '2024-12-20 17:12:01', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16533', '1', '2024-12-20', '77', '0','1653301','220','220','220','160','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16533', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16533', '1', '0', '0', '16533', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:42:01";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:12:01", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:12:01', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:42:12";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:12:12", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:12:12', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:42:32";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:12:32", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:12:32', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765892715aa8', '2024-12-20 17:11:35', '56', '49060.00', '51460', '0', '0', '2400',  '2400', '0', '2400', '1', '2024-12-20 17:12:32', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07355', '14177', '5', '16533', '15', '160', '2400', '0', '', '2024-12-20 17:12:32', '16533','','','0','0','0','0','0',null,'160','2400','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 17:11:35', 1, 16533, 0, 0
                    , 160, 15, 0, 0, 77, '2024-12-20 17:12:32')
                ON DUPLICATE KEY UPDATE buyprice = 160,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 17:12:32' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16533', '160', '15', '0', 'buyBillController.php', '32809', '', '0', '0');
UPDATE product SET  productBuyPrice = "160" WHERE productId = 16533 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32809 ;
UPDATE product SET productName = '7355', productDescription = '', productCatId = '5', productBuyPrice = '160.00', productSellAllPrice = '220.00', productSellUnitPrice = '220.00', productSellHalfPrice = '220.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07355',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '160',lastbuyprice_withDiscount = '160',meanbuyprice = '160',meanbuyprice_withDiscount = '160' , productbuypricereal = '160.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='160',meanbuyprice_withTax='160',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='160'  WHERE productId = '16533';
UPDATE buybilldetail SET  lastbuyprice = 160 , meanbuyprice = 160, lastbuyprice_withDiscount = 160, meanbuyprice_withDiscount = 160
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 160, lastbuyprice_withDiscountAndTax = 160
                where buybilldetailid = 32809;
UPDATE productunit SET proUnitBuyPrice  = 160 * productnumber WHERE productid = 16533;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16532';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16533', '1', '15', '0', '14177', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 17:11:35','0','0');
UPDATE supplier SET  suppliercurrentDebt = '51460',suppliercurrentDebtInCurrency= '51460' , userid = '77', supplierdate = '2024-12-20 17:12:32'   WHERE supplierid = '56';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('56', '49060.00', '2400', '0', 'اضافة فاتورة مشتريات', '14177', '51460', '2024-12-20 17:11:35', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','2400','1','49060','2400','51460','0');
update buybill set dailyentryid='0,' where buybillid=14177;
COMMIT;
UPDATE product SET overAllAveragePrice = 160 WHERE productId = 16533;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:42:32";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:12:32", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:12:32', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14177');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:42:37";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:12:37", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:12:37', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:43:07";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:13:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:13:07', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:43:20";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:13:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:13:20', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:43:57";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:13:57", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:13:57', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:44:34";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:14:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 17:14:34', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:44:49";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:14:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 17:14:49', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7360','','5','140','200', '200','200', '2024-12-20', '0', '77', '1', '07360', '0', '0', '0', '0', '0', '140','140','140','140','140','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','140','140','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16534, 1,'2024-12-20 17:15:04',77)
                ON DUPLICATE KEY UPDATE productid = 16534, edited = 1, sysdate = '2024-12-20 17:15:04', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16534', '1', '2024-12-20', '77', '0','1653401','200','200','200','140','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16534', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16534', '1', '0', '0', '16534', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7359','','5','140','200', '200','200', '2024-12-20', '0', '77', '1', '07359', '0', '0', '0', '0', '0', '140','140','140','140','140','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','140','140','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16535, 1,'2024-12-20 17:15:24',77)
                ON DUPLICATE KEY UPDATE productid = 16535, edited = 1, sysdate = '2024-12-20 17:15:24', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16535', '1', '2024-12-20', '77', '0','1653501','200','200','200','140','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16535', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16535', '1', '0', '0', '16535', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:45:34";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:15:34", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:15:34', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676587ca12fa0
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7091,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:05:46', '0676587ca12fa0', '7091', '2266.00', '5438', '0', '1', '3172.00', '3172', '0', '3172', '1', '2024-12-20 17:15:34', '', '75', '0', 'تقي صلاح Y3', '2', '1', '3', '80', 'تقي صلاح Y3', '21' ,'0','','','','','-1','0','0','0','0','0','3172','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '5438', userid = '75' WHERE clientid = '7091';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7091','2266.00','3172','0','اضافة فاتورة مبيعات','150449', '5438', '2024-12-20 17:15:34', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3172', '0', null, '0', null, null,'', '0','1','1','3172','1','2024-12-20 17:05:46','0','0');
UPDATE client SET  inUse = 0 where clientid = 7091;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 34716;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('160','06879', '150449', '5', '15669', '3', '145', '435', '0', '', '1', '2024-12-20 17:15:34', '15669', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34716-3,','1','1','0','0','145','435','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 160, lastbuyprice_withDiscountAndTax = 160
                where sellbilldetailid = 549706;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15669, '2024-12-20', 435, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+435, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 435, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+435, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 17:15:34' WHERE storedetailid = '15668';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15669', '1', '3', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '1', '75', '2024-12-20 17:15:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34715;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','06891', '150449', '5', '15664', '1', '145', '145', '0', '', '1', '2024-12-20 17:15:34', '15664', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34715-1,','1','1','0','0','145','145','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549707;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15664, '2024-12-20', 145, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+145, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 145, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+145, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 17:15:34' WHERE storedetailid = '15663';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15664', '1', '1', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 17:15:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35571;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','06934', '150449', '5', '15820', '2', '135', '270', '0', '', '1', '2024-12-20 17:15:34', '15820', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35571-2,','1','1','0','0','135','270','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549708;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15820, '2024-12-20', 270, 280, 280
                    , 280, 280, 280, 282.22
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+282.22
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 270, 280, 280
                    , 280, 280, 280, 282.22
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+282.22
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 17:15:34' WHERE storedetailid = '15819';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15820', '1', '2', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '3', '75', '2024-12-20 17:15:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36300;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','06959', '150449', '5', '15856', '2', '200', '400', '0', '', '1', '2024-12-20 17:15:34', '15856', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36300-2,','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549709;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15856, '2024-12-20', 400, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '17', userid = '75', storedetaildate = '2024-12-20 17:15:34' WHERE storedetailid = '15855';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15856', '1', '2', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '17', '75', '2024-12-20 17:15:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 34549;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','06885', '150449', '5', '15662', '2', '145', '290', '0', '', '1', '2024-12-20 17:15:34', '15662', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34549-2,','1','1','0','0','145','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549710;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15662, '2024-12-20', 290, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-20 17:15:34' WHERE storedetailid = '15661';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15662', '1', '2', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '0', '75', '2024-12-20 17:15:34','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('135','R2791', '150449', '1', '13897', '1', '95', '95', '0', '', '1', '2024-12-20 17:15:35', '13897', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','95','95','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 135.00 , meanbuyprice = 135.00, lastbuyprice_withDiscount = 135.00, meanbuyprice_withDiscount = 135.00
        
                where sellbilldetailid = 549711;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13897, '2024-12-20', 95, 135, 135
                    , 135, 135, 135, 135
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+95, sellCostBuyPrice =sellCostBuyPrice+135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+135, sellCostMeanBuyPrice = sellCostMeanBuyPrice+135
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+135
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+135
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 95, 135, 135
                    , 135, 135, 135, 135
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+95, sellCostBuyPrice =sellCostBuyPrice+135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+135, sellCostMeanBuyPrice = sellCostMeanBuyPrice+135
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+135
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+135
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 17:15:35' WHERE storedetailid = '13896';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13897', '1', '1', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 17:15:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31298;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('385','0A280', '150449', '6', '14072', '1', '295', '295', '0', '', '1', '2024-12-20 17:15:35', '14072', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31298-1,','1','1','0','0','295','295','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 385.00 , meanbuyprice = 385.00, lastbuyprice_withDiscount = 385.00, meanbuyprice_withDiscount = 385.00
        
                where sellbilldetailid = 549712;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14072, '2024-12-20', 295, 385, 385
                    , 385, 385, 385, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+295, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 295, 385, 385
                    , 385, 385, 385, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+295, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-20 17:15:35' WHERE storedetailid = '14071';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14072', '1', '1', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-20 17:15:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36121;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','10445', '150449', '5', '16347', '1', '200', '200', '0', '', '1', '2024-12-20 17:15:35', '16347', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36121-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 137.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 137.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 134, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549713;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16347, '2024-12-20', 200, 140, 140
                    , 137, 140, 137, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 134, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+137
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+137
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+134
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 137, 140, 137, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 134, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+137
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+137
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+134
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '75', storedetaildate = '2024-12-20 17:15:35' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '1', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-20 17:15:35','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('300','R2757', '150449', '1', '13526', '1', '185', '185', '0', '', '1', '2024-12-20 17:15:35', '13526', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        
                where sellbilldetailid = 549714;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13526, '2024-12-20', 185, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 185, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '75', storedetaildate = '2024-12-20 17:15:35' WHERE storedetailid = '13525';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13526', '1', '1', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '75', '2024-12-20 17:15:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31706;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('160','R2816', '150449', '1', '14039', '1', '130', '130', '0', '', '1', '2024-12-20 17:15:35', '14039', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31706-1,','1','1','0','0','130','130','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        
                where sellbilldetailid = 549715;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14039, '2024-12-20', 130, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 130, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-20 17:15:35' WHERE storedetailid = '14038';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14039', '1', '1', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-20 17:15:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31588;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('120','R2852', '150449', '1', '14199', '1', '95', '95', '0', '', '1', '2024-12-20 17:15:35', '14199', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31588-1,','1','1','0','0','95','95','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 120.00 , meanbuyprice = 120.00, lastbuyprice_withDiscount = 120.00, meanbuyprice_withDiscount = 120.00
        
                where sellbilldetailid = 549716;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14199, '2024-12-20', 95, 120, 120
                    , 120, 120, 120, 120
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+95, sellCostBuyPrice =sellCostBuyPrice+120
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+120, sellCostMeanBuyPrice = sellCostMeanBuyPrice+120
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+120, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+120
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+120
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 95, 120, 120
                    , 120, 120, 120, 120
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+95, sellCostBuyPrice =sellCostBuyPrice+120
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+120, sellCostMeanBuyPrice = sellCostMeanBuyPrice+120
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+120, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+120
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+120
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-20 17:15:35' WHERE storedetailid = '14198';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14199', '1', '1', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-20 17:15:35','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('180','عرض 180', '150449', '18', '10349', '2', '190', '380', '0', '', '1', '2024-12-20 17:15:35', '10349', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','190','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
        
                where sellbilldetailid = 549717;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10349, '2024-12-20', 380, 360, 360
                    , 360, 360, 360, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 380, 360, 360
                    , 360, 360, 360, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-9', userid = '75', storedetaildate = '2024-12-20 17:15:35' WHERE storedetailid = '10348';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10349', '1', '2', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-7', '-9', '75', '2024-12-20 17:15:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29417;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('170','R2684', '150449', '1', '13142', '1', '200', '200', '0', '', '1', '2024-12-20 17:15:35', '13142', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29417-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 255.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 255.00
        
                where sellbilldetailid = 549718;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13142, '2024-12-20', 200, 170, 170
                    , 255, 170, 255, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 170, 170
                    , 255, 170, 255, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '75', storedetaildate = '2024-12-20 17:15:35' WHERE storedetailid = '13141';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13142', '1', '1', '1', '150449', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '75', '2024-12-20 17:15:35','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150449', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 17:15:35', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150449', '17', '10291', '1', '32', '32', '0', '', '1', '2024-12-20 17:15:35', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','32','32','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 80 where clientid = 7091;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 3172, 3265, 3265
                    , 3347, 3265, 3347, 2907.22
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1635, 1629, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3172, sellCostBuyPrice =sellCostBuyPrice+3265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3347
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3347
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2907.22
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1635
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1629
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7091, '2024-12-20', 3172, 3265, 3265
                    , 3347, 3265, 3347, 2907.22
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1635, 1629, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3172, sellCostBuyPrice =sellCostBuyPrice+3265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3347
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3347
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2907.22
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1635
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1629
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3172, 3265, 3265
                    , 3347, 3265, 3347, 2907.22, 1635, 1629)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3172, netSellCostBuyPrice = netSellCostBuyPrice+3265
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3265
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+3347
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3265
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+3347
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2907.22
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1635
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1629;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676587ca12fa0 and sellbillId = 150449 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:45:36";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:15:36", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:15:36', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:45:48";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:15:48", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:15:48', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658965794a7
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(347,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:12:37', '067658965794a7', '347', '4.00', '585', '0', '1', '581.00', '581', '0', '581', '1', '2024-12-20 17:15:48', '', '101', '0', 'سهيلة محمد y35', '2', '1', '3', '83', 'سهيلة محمد y35', '5' ,'0','','','','','-1','0','0','0','0','0','581','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '585', userid = '101' WHERE clientid = '347';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('347','4.00','581','0','اضافة فاتورة مبيعات','150450', '585', '2024-12-20 17:15:48', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '581', '0', null, '0', null, null,'', '0','1','1','581','1','2024-12-20 17:12:37','0','0');
UPDATE client SET  inUse = 0 where clientid = 347;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35111;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('180','06926', '150450', '5', '15787', '1', '240', '240', '0', '', '1', '2024-12-20 17:15:48', '15787', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35111-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
        , lastbuyprice_withTax = 180, meanbuyprice_withTax = 180, lastbuyprice_withDiscountAndTax = 180
                where sellbilldetailid = 549721;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15787, '2024-12-20', 240, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+180
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 240, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+180
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 17:15:48' WHERE storedetailid = '15786';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15787', '1', '1', '1', '150450', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '101', '2024-12-20 17:15:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34375;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('190','06832', '150450', '5', '15543', '1', '155', '155', '0', '', '1', '2024-12-20 17:15:49', '15543', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34375-1,','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        
                where sellbilldetailid = 549722;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15543, '2024-12-20', 155, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 17:15:49' WHERE storedetailid = '15542';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15543', '1', '1', '1', '150450', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '101', '2024-12-20 17:15:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36381;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('110','R3342', '150450', '1', '16446', '1', '160', '160', '0', '', '1', '2024-12-20 17:15:49', '16446', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36381-1,','1','1','0','0','160','160','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 110.00 , meanbuyprice = 110.00, lastbuyprice_withDiscount = 110.00, meanbuyprice_withDiscount = 110.00
        , lastbuyprice_withTax = 110, meanbuyprice_withTax = 110, lastbuyprice_withDiscountAndTax = 110
                where sellbilldetailid = 549723;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16446, '2024-12-20', 160, 110, 110
                    , 110, 110, 110, 110
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 110, 110, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+160, sellCostBuyPrice =sellCostBuyPrice+110
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+110, sellCostMeanBuyPrice = sellCostMeanBuyPrice+110
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+110, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+110
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+110
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+110
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+110
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 160, 110, 110
                    , 110, 110, 110, 110
                    , 0, 0, 0, 0
                    , 0, 0, 0, 110, 110, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+160, sellCostBuyPrice =sellCostBuyPrice+110
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+110, sellCostMeanBuyPrice = sellCostMeanBuyPrice+110
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+110, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+110
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+110
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+110
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+110
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '21', userid = '101', storedetaildate = '2024-12-20 17:15:49' WHERE storedetailid = '16445';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16446', '1', '1', '1', '150450', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '101', '2024-12-20 17:15:49','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150450', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 17:15:49', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150450', '17', '10291', '1', '6', '6', '0', '', '1', '2024-12-20 17:15:49', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','6','6','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 83 where clientid = 347;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 581, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,290, 290, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+581, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+290
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+290
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (347, '2024-12-20', 581, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,290, 290, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+581, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+290
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+290
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 581, 480, 480
                    , 480, 480, 480, 480, 290, 290)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+581, netSellCostBuyPrice = netSellCostBuyPrice+480
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+480
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+480
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+480
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+480
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+480
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+290
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+290;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658965794a7 and sellbillId = 150450 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:45:49";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:15:49", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:15:49', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:45:51";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:15:51", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:15:51', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('0676589b59ca79', '2024-12-20 17:13:57', '56', '51460.00', '60160', '0', '0', '8700',  '8700', '0', '8700', '1', '2024-12-20 17:15:51', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07269', '14178', '5', '16378', '15', '160', '2400', '0', '', '2024-12-20 17:15:51', '16378','','','0','0','0','0','0',null,'160','2400','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 17:13:57', 1, 16378, 0, 0
                    , 160, 15, 0, 0, 77, '2024-12-20 17:15:51')
                ON DUPLICATE KEY UPDATE buyprice = 160,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 17:15:51' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16378', '160', '15', '0', 'buyBillController.php', '32810', '', '0', '0');
UPDATE product SET  productBuyPrice = "160" WHERE productId = 16378 ;
UPDATE buybilldetail SET  quantitybefore = 7 WHERE buybilldetailid = 32810 ;
UPDATE product SET productName = '7269', productDescription = '', productCatId = '5', productBuyPrice = '160.00', productSellAllPrice = '220.00', productSellUnitPrice = '220.00', productSellHalfPrice = '220.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07269',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '160',lastbuyprice_withDiscount = '160',meanbuyprice = '160',meanbuyprice_withDiscount = '160' , productbuypricereal = '160.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='160',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='160',meanbuyprice_withTax='160',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='160'  WHERE productId = '16378';
UPDATE buybilldetail SET  lastbuyprice = 160 , meanbuyprice = 160, lastbuyprice_withDiscount = 160, meanbuyprice_withDiscount = 160
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 160, lastbuyprice_withDiscountAndTax = 160
                where buybilldetailid = 32810;
UPDATE productunit SET proUnitBuyPrice  = 160 * productnumber WHERE productid = 16378;
UPDATE storedetail SET  productquantity = '22', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16377';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16378', '1', '15', '0', '14178', 'اضافة فاتورة مشتريات', 'buyBillController.php', '7', '22', '77', '2024-12-20 17:13:57','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07264', '14178', '5', '16385', '15', '140', '2100', '0', '', '2024-12-20 17:15:51', '16385','','','0','0','0','0','0',null,'140','2100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 17:13:57', 1, 16385, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-20 17:15:51')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 17:15:51' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16385', '140', '15', '0', 'buyBillController.php', '32811', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16385 ;
UPDATE buybilldetail SET  quantitybefore = 6 WHERE buybilldetailid = 32811 ;
UPDATE product SET productName = '7264', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07264',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140',meanbuyprice_withDiscount = '140' , productbuypricereal = '140.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='140',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='120',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '16385';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 120, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32811;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16385;
UPDATE storedetail SET  productquantity = '21', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16384';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16385', '1', '15', '0', '14178', 'اضافة فاتورة مشتريات', 'buyBillController.php', '6', '21', '77', '2024-12-20 17:13:57','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07360', '14178', '5', '16534', '15', '140', '2100', '0', '', '2024-12-20 17:15:51', '16534','','','0','0','0','0','0',null,'140','2100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 17:13:57', 1, 16534, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-20 17:15:51')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 17:15:51' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16534', '140', '15', '0', 'buyBillController.php', '32812', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16534 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32812 ;
UPDATE product SET productName = '7360', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07360',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140',meanbuyprice_withDiscount = '140' , productbuypricereal = '140.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='140',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '16534';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32812;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16534;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16533';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16534', '1', '15', '0', '14178', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 17:13:57','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07359', '14178', '5', '16535', '15', '140', '2100', '0', '', '2024-12-20 17:15:51', '16535','','','0','0','0','0','0',null,'140','2100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 17:13:57', 1, 16535, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-20 17:15:51')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 17:15:51' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16535', '140', '15', '0', 'buyBillController.php', '32813', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16535 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32813 ;
UPDATE product SET productName = '7359', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07359',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140',meanbuyprice_withDiscount = '140' , productbuypricereal = '140.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='140',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '16535';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32813;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16535;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16534';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16535', '1', '15', '0', '14178', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 17:13:57','0','0');
UPDATE supplier SET  suppliercurrentDebt = '60160',suppliercurrentDebtInCurrency= '60160' , userid = '77', supplierdate = '2024-12-20 17:15:51'   WHERE supplierid = '56';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('56', '51460.00', '8700', '0', 'اضافة فاتورة مشتريات', '14178', '60160', '2024-12-20 17:13:57', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','8700','1','51460','8700','60160','0');
update buybill set dailyentryid='0,' where buybillid=14178;
COMMIT;
UPDATE product SET overAllAveragePrice = 160 WHERE productId = 16378;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16385;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16534;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16535;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:45:52";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:15:52", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 17:15:52', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14178');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:46:10";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:16:10", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:16:10', '101', 'showDetail', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150450');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:46:41";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:16:41", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 17:16:41', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:46:47";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:16:47", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 17:16:47', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE userid = 101;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:48:44";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 17:18:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 17:18:44', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:48:45";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:48:55";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 17:18:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:18:55', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:49:03";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 17:19:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:19:03', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:49:04";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:19:04", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:19:04', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:49:31";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 17:19:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:19:31', '2', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150450');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:49:32";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:19:32", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:19:32', '101', 'editsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150340');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:49:52";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:19:52", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:19:52', '101', 'update', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 150340 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 150340 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150340;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 17:19:52', userid = '75',delbyuserid = '101', conditions = '1'  WHERE sellbillid = '150340';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 32064;
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 466.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 466.00
        
                where sellbilldetailid = 549226;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14424, '2024-12-20', 265, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-265, sellCostBuyPrice =sellCostBuyPrice-225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-225, sellCostMeanBuyPrice = sellCostMeanBuyPrice-466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 265, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-265, sellCostBuyPrice =sellCostBuyPrice-225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-225, sellCostMeanBuyPrice = sellCostMeanBuyPrice-466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 17:19:52' WHERE storedetailid = '14423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14424', '1', '1', '0', '150340', 'تعديل فاتورة مبيعات', 'sellbillController.php', '1', '2', '101', '2024-12-20 12:00:45','0','0');
CALL clientInUse(10142,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '20', userid = '101' WHERE clientid = '10142';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10142','288.00','268.00','1','تعديل فاتورة مبيعات','150340', '20', '2024-12-20 12:00:45', '101', 'sellbillController.php', 'تعديل فاتورة مبيعات', '268', '0', null, '0', null, null,'', '0','1','1','268','1','2024-12-20 12:00:45','0','0');
UPDATE client SET  inUse = 0 where clientid = 10142;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 268, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-268, sellCostBuyPrice =sellCostBuyPrice-225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-225, sellCostMeanBuyPrice = sellCostMeanBuyPrice-466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10142, '2024-12-20', 268, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-268, sellCostBuyPrice =sellCostBuyPrice-225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-225, sellCostMeanBuyPrice = sellCostMeanBuyPrice-466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 268, 225, 225
                    , 466, 225, 466, 225, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-268, netSellCostBuyPrice = netSellCostBuyPrice-225
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-225
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-466
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-225
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-466
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-225
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-0;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 150340 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 150340 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(10142,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 12:00:45', '06765404d8cc2d', '10142', '20.00', '212', '0', '1', '192', '192', '0', '192', '1', '2024-12-20 12:00:45', '', '101', '0', 'رانا نبيل 100', '2', '1', '3', '83', 'رانا نبيل 100', '2', '150340', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '212', userid = '101' WHERE clientid = '10142';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10142','20.00','192','0','اضافة فاتورة مبيعات (معدله)','150451', '212', '2024-12-20 17:19:52', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '192', '0', null, '0', null, null,'', '0','1','1','268','1','2024-12-20 12:00:45','0','0');
UPDATE client SET  inUse = 0 where clientid = 10142;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32064;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06343', '150451', '5', '14424', '1', '190', '190', '0', '', '1', '2024-12-20 17:19:52', '14424', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32064-1,','1','1','0','0','190','190','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 466.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 466.00
        
                where sellbilldetailid = 549726;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14424, '2024-12-20', 190, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 190, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '101', storedetaildate = '2024-12-20 17:19:52' WHERE storedetailid = '14423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14424', '1', '1', '1', '150451', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '2', '1', '101', '2024-12-20 17:19:52','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150451', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-20 17:19:52', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','2','2','0','','0','0.00','0','0','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 192, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+192, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10142, '2024-12-20', 192, 225, 225
                    , 466, 225, 466, 225
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+192, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+225
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 192, 225, 225
                    , 466, 225, 466, 225, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+192, netSellCostBuyPrice = netSellCostBuyPrice+225
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+225
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+466
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+225
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+466
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+225
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150340 and newid=150451 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:49:53";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:19:53", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:19:53', '101', 'editprint', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150451');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:50:08";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:20:08", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 17:20:08', '77', 'all', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=all');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:50:19";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:20:19", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 17:20:19', '77', 'all', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=all');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:51:11";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:21:11", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:21:11', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658a184ffb8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9047,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:15:36', '067658a184ffb8', '9047', '-49.00', '3739', '0', '1', '3788.00', '3788', '0', '3788', '1', '2024-12-20 17:21:11', '', '75', '0', 'مي السويس  B503', '2', '1', '3', '90', 'مي السويس  B503', '12' ,'0','','','','','-1','0','0','0','0','0','3788','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '3739', userid = '75' WHERE clientid = '9047';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9047','-49.00','3788','0','اضافة فاتورة مبيعات','150452', '3739', '2024-12-20 17:21:11', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3788', '0', null, '0', null, null,'', '0','1','1','3788','1','2024-12-20 17:15:36','0','0');
UPDATE client SET  inUse = 0 where clientid = 9047;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36361;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('720','H1660', '150452', '14', '16431', '1', '830', '830', '0', '', '1', '2024-12-20 17:21:11', '16431', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36361-1,','1','1','0','0','830','830','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 720.00 , meanbuyprice = 720.00, lastbuyprice_withDiscount = 720.00, meanbuyprice_withDiscount = 720.00
        , lastbuyprice_withTax = 720, meanbuyprice_withTax = 720, lastbuyprice_withDiscountAndTax = 720
                where sellbilldetailid = 549728;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16431, '2024-12-20', 830, 720, 720
                    , 720, 720, 720, 720
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 720, 720, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+830, sellCostBuyPrice =sellCostBuyPrice+720
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+720, sellCostMeanBuyPrice = sellCostMeanBuyPrice+720
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+720, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+720
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+720
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+720
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+720
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 830, 720, 720
                    , 720, 720, 720, 720
                    , 0, 0, 0, 0
                    , 0, 0, 0, 720, 720, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+830, sellCostBuyPrice =sellCostBuyPrice+720
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+720, sellCostMeanBuyPrice = sellCostMeanBuyPrice+720
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+720, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+720
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+720
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+720
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+720
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '75', storedetaildate = '2024-12-20 17:21:11' WHERE storedetailid = '16430';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16431', '1', '1', '1', '150452', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-20 17:21:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35954;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07120', '150452', '5', '16123', '2', '200', '400', '0', '', '1', '2024-12-20 17:21:11', '16123', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35954-2,','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549729;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16123, '2024-12-20', 400, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '37', userid = '75', storedetaildate = '2024-12-20 17:21:11' WHERE storedetailid = '16122';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16123', '1', '2', '1', '150452', 'اضافة فاتورة مبيعات', 'sellbillController.php', '39', '37', '75', '2024-12-20 17:21:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36306;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','06934', '150452', '5', '15820', '2', '135', '270', '0', '', '1', '2024-12-20 17:21:11', '15820', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36306-2,','1','1','0','0','135','270','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549730;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15820, '2024-12-20', 270, 280, 280
                    , 280, 280, 280, 282.22
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+282.22
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 270, 280, 280
                    , 280, 280, 280, 282.22
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+282.22
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 17:21:11' WHERE storedetailid = '15819';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15820', '1', '2', '1', '150452', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '1', '75', '2024-12-20 17:21:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36094;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('730','07143', '150452', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-20 17:21:11', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36094-1,','1','1','0','0','810','810','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 730.00 , meanbuyprice = 730.00, lastbuyprice_withDiscount = 730.00, meanbuyprice_withDiscount = 730.00
        , lastbuyprice_withTax = 730, meanbuyprice_withTax = 730, lastbuyprice_withDiscountAndTax = 730
                where sellbilldetailid = 549731;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16205, '2024-12-20', 810, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+730
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+730, sellCostMeanBuyPrice = sellCostMeanBuyPrice+730
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+730, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+730
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+730
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+730
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+730
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 810, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0, 730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+730
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+730, sellCostMeanBuyPrice = sellCostMeanBuyPrice+730
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+730, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+730
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+730
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+730
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+730
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '57', userid = '75', storedetaildate = '2024-12-20 17:21:11' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '150452', 'اضافة فاتورة مبيعات', 'sellbillController.php', '58', '57', '75', '2024-12-20 17:21:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36469;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('335','07221', '150452', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-20 17:21:11', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36469-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 549732;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16279, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '56', userid = '75', storedetaildate = '2024-12-20 17:21:11' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150452', 'اضافة فاتورة مبيعات', 'sellbillController.php', '57', '56', '75', '2024-12-20 17:21:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35790;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','78808', '150452', '5', '15674', '2', '360', '720', '0', '', '1', '2024-12-20 17:21:11', '15674', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35790-2,','1','1','0','0','360','720','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 295.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 295.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295
                where sellbilldetailid = 549733;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15674, '2024-12-20', 720, 590, 590
                    , 590, 590, 590, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 590, 590, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+590
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+590
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+590
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+590
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+590
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 720, 590, 590
                    , 590, 590, 590, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0, 590, 590, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+590
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+590
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+590
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+590
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+590
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '28', userid = '75', storedetaildate = '2024-12-20 17:21:11' WHERE storedetailid = '15673';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15674', '1', '2', '1', '150452', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30', '28', '75', '2024-12-20 17:21:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36249;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','06861', '150452', '5', '15635', '1', '300', '300', '0', '', '1', '2024-12-20 17:21:11', '15635', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36249-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 241, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549734;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15635, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 236.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 241, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+236.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+241
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 236.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 241, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+236.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+241
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '75', storedetaildate = '2024-12-20 17:21:11' WHERE storedetailid = '15634';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15635', '1', '1', '1', '150452', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-20 17:21:11','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150452', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 17:21:11', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150452', '17', '10291', '1', '38', '38', '0', '', '1', '2024-12-20 17:21:11', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','38','38','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 90 where clientid = 9047;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 3788, 3175, 3175
                    , 3175, 3175, 3175, 3173.89
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3175, 3164, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3788, sellCostBuyPrice =sellCostBuyPrice+3175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3175
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3175
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3173.89
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3175
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3164
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9047, '2024-12-20', 3788, 3175, 3175
                    , 3175, 3175, 3175, 3173.89
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3175, 3164, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3788, sellCostBuyPrice =sellCostBuyPrice+3175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3175
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3175
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3173.89
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3175
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3164
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3788, 3175, 3175
                    , 3175, 3175, 3175, 3173.89, 3175, 3164)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3788, netSellCostBuyPrice = netSellCostBuyPrice+3175
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3175
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+3175
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3175
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+3175
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+3173.89
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+3175
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+3164;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658a184ffb8 and sellbillId = 150452 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:51:12";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:21:12", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:21:12', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:51:19";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:21:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 17:21:19', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:51:48";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:21:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 17:21:48', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'محمد عبدة', '', '50', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '6900',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6950.00','50', '1', '1', 'إضافة مصروف', '25911', '6900', '2024-12-20 17:21:48', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد عبدة', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25911';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:51:48";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:21:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 17:21:48', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:51:50";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:21:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 17:21:50', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:53:58";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:23:58", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:23:58', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658b68880ea
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5787,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:21:12', '067658b68880ea', '5787', '20.00', '1828', '0', '1', '1808.00', '1808', '0', '1808', '1', '2024-12-20 17:23:58', '', '75', '0', 'شيماء فكري F4', '2', '1', '3', '86', 'شيماء فكري F4', '9' ,'0','','','','','-1','0','0','0','0','0','1808','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1828', userid = '75' WHERE clientid = '5787';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5787','20.00','1808','0','اضافة فاتورة مبيعات','150453', '1828', '2024-12-20 17:23:58', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1808', '0', null, '0', null, null,'', '0','1','1','1808','1','2024-12-20 17:21:12','0','0');
UPDATE client SET  inUse = 0 where clientid = 5787;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36360;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('230','H1630', '150453', '14', '16292', '1', '300', '300', '0', '', '1', '2024-12-20 17:23:58', '16292', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36360-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where sellbilldetailid = 549737;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16292, '2024-12-20', 300, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '25', userid = '75', storedetaildate = '2024-12-20 17:23:58' WHERE storedetailid = '16291';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16292', '1', '1', '1', '150453', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '75', '2024-12-20 17:23:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36349;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('185','H1619', '150453', '14', '16298', '2', '250', '500', '0', '', '1', '2024-12-20 17:23:58', '16298', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36349-2,','1','1','0','0','250','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 185.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 185.00
        , lastbuyprice_withTax = 185, meanbuyprice_withTax = 185, lastbuyprice_withDiscountAndTax = 185
                where sellbilldetailid = 549738;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16298, '2024-12-20', 500, 370, 370
                    , 370, 370, 370, 370
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 370, 370, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+370
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+370
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+370
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 500, 370, 370
                    , 370, 370, 370, 370
                    , 0, 0, 0, 0
                    , 0, 0, 0, 370, 370, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+370
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+370
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+370
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '21', userid = '75', storedetaildate = '2024-12-20 17:23:58' WHERE storedetailid = '16297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16298', '1', '2', '1', '150453', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '21', '75', '2024-12-20 17:23:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36389;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('310','07301', '150453', '5', '16451', '1', '390', '390', '0', '', '1', '2024-12-20 17:23:58', '16451', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36389-1,','1','1','0','0','390','390','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 310.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 310.00
        , lastbuyprice_withTax = 310, meanbuyprice_withTax = 310, lastbuyprice_withDiscountAndTax = 310
                where sellbilldetailid = 549739;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16451, '2024-12-20', 390, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 390, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '23', userid = '75', storedetaildate = '2024-12-20 17:23:58' WHERE storedetailid = '16450';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16451', '1', '1', '1', '150453', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '75', '2024-12-20 17:23:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36368;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('150','07296', '150453', '5', '16435', '1', '200', '200', '0', '', '1', '2024-12-20 17:23:58', '16435', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36368-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        , lastbuyprice_withTax = 150, meanbuyprice_withTax = 150, lastbuyprice_withDiscountAndTax = 150
                where sellbilldetailid = 549740;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16435, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+150
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '75', storedetaildate = '2024-12-20 17:23:58' WHERE storedetailid = '16434';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16435', '1', '1', '1', '150453', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-20 17:23:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36128;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07264', '150453', '5', '16385', '1', '200', '200', '0', '', '1', '2024-12-20 17:23:58', '16385', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36128-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 120, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549741;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16385, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 120, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+120
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 120, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+120
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '75', storedetaildate = '2024-12-20 17:23:58' WHERE storedetailid = '16384';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16385', '1', '1', '1', '150453', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '75', '2024-12-20 17:23:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36369;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('135','21133', '150453', '5', '16436', '1', '180', '180', '0', '', '1', '2024-12-20 17:23:58', '16436', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36369-1,','1','1','0','0','180','180','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 135.00 , meanbuyprice = 135.00, lastbuyprice_withDiscount = 135.00, meanbuyprice_withDiscount = 135.00
        , lastbuyprice_withTax = 135, meanbuyprice_withTax = 135, lastbuyprice_withDiscountAndTax = 135
                where sellbilldetailid = 549742;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16436, '2024-12-20', 180, 135, 135
                    , 135, 135, 135, 135
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 135, 135, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+135, sellCostMeanBuyPrice = sellCostMeanBuyPrice+135
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+135
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+135
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+135
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+135
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 180, 135, 135
                    , 135, 135, 135, 135
                    , 0, 0, 0, 0
                    , 0, 0, 0, 135, 135, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+135, sellCostMeanBuyPrice = sellCostMeanBuyPrice+135
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+135
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+135
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+135
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+135
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '75', storedetaildate = '2024-12-20 17:23:58' WHERE storedetailid = '16435';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16436', '1', '1', '1', '150453', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-20 17:23:58','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150453', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 17:23:58', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150453', '17', '10291', '1', '18', '18', '0', '', '1', '2024-12-20 17:23:58', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','18','18','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 86 where clientid = 5787;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1808, 1335, 1335
                    , 1335, 1335, 1335, 1335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1335, 1315, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1808, sellCostBuyPrice =sellCostBuyPrice+1335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1315
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (5787, '2024-12-20', 1808, 1335, 1335
                    , 1335, 1335, 1335, 1335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1335, 1315, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1808, sellCostBuyPrice =sellCostBuyPrice+1335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1315
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1808, 1335, 1335
                    , 1335, 1335, 1335, 1335, 1335, 1315)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1808, netSellCostBuyPrice = netSellCostBuyPrice+1335
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1335
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1335
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1335
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1335
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1335
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1335
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1315;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658b68880ea and sellbillId = 150453 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:53:59";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:23:59", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:23:59', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:56:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:26:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:26:27', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:57:59";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:27:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:27:59', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658ca3e48c1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:26:27', '067658ca3e48c1', '1', '0.00', '0', '0', '1', '510.00', '510', '510', '0', '1', '2024-12-20 17:27:59', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','510','0','','0','0','510','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150454', '0', '2024-12-20 17:27:59', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '510', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 17:26:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35888;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07213', '150454', '5', '16286', '1', '210', '210', '0', '', '1', '2024-12-20 17:27:59', '16286', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35888-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549745;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16286, '2024-12-20', 210, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '104', storedetaildate = '2024-12-20 17:27:59' WHERE storedetailid = '16285';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16286', '1', '1', '1', '150454', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-20 17:27:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36174;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','07172', '150454', '5', '16239', '1', '300', '300', '0', '', '1', '2024-12-20 17:27:59', '16239', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36174-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549746;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16239, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '104', storedetaildate = '2024-12-20 17:27:59' WHERE storedetailid = '16238';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16239', '1', '1', '1', '150454', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '104', '2024-12-20 17:27:59','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7410',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6900','510', '0', '1', 'اضافة فاتورة مبيعات', '150454', '7410', '2024-12-20 17:27:59', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 510, 395, 395
                    , 395, 395, 395, 395
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,395, 395, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+395, sellCostMeanBuyPrice = sellCostMeanBuyPrice+395
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+395
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+395
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+395
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+395
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 510, 395, 395
                    , 395, 395, 395, 395
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,395, 395, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+395, sellCostMeanBuyPrice = sellCostMeanBuyPrice+395
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+395
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+395
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+395
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+395
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 510, 395, 395
                    , 395, 395, 395, 395, 395, 395)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+510, netSellCostBuyPrice = netSellCostBuyPrice+395
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+395
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+395
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+395
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+395
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+395
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+395
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+395;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658ca3e48c1 and sellbillId = 150454 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:58:00";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:28:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:28:00', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:58:40";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:28:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 17:28:40', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 13:58:48";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:28:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 17:28:48', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:00:11";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:30:11", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:30:11', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:00:24";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:30:24", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:30:24', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:00:57";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:30:57", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:30:57', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:01:09";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:31:09", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:31:09', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:02:50";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:32:50", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:32:50', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:05:13";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:35:13", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:35:13', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('زياد محمود 25' , '', '', '01273158135', '0', '', '0', '2024-12-20 17:35:40', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10776', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10776','0','0','0','إضافة عميل جديد','10776', '0', '2024-12-20 17:35:40', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('زياد محمود 25', 'زياد محمود 25', 'زياد محمود 25', 'زياد محمود 25', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-20 17:35:40');
UPDATE client SET clientname = 'زياد محمود 25', clientaddress = '', clientphone = '', clientmobile = '01273158135', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '75'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12621',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10776';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:07:03";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:37:03", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 17:37:03', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:07:15";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:37:15", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:37:15', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:07:18";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:37:18", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:37:18', '101', 'showDetail', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150437');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:09:25";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:39:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:39:25', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:09:38";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:39:38", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:39:38', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658eb1a6cf8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10776,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:35:13', '067658eb1a6cf8', '10776', '0.00', '9414', '0', '1', '9414.00', '9414', '0', '9414', '1', '2024-12-20 17:39:39', '', '75', '0', 'زياد محمود 25', '2', '1', '3', '78', 'زياد محمود 25', '17' ,'0','','','','','-1','0','0','0','0','0','9414','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '9414', userid = '75' WHERE clientid = '10776';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10776','0.00','9414','0','اضافة فاتورة مبيعات','150455', '9414', '2024-12-20 17:39:39', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '9414', '0', null, '0', null, null,'', '0','1','1','9414','1','2024-12-20 17:35:13','0','0');
UPDATE client SET  inUse = 0 where clientid = 10776;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+5 where id = 35935;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('480','07193', '150455', '5', '16309', '15', '620', '9300', '0', '', '1', '2024-12-20 17:39:39', '16309', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35935-5,','1','1','0','0','620','9300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 480.00 , meanbuyprice = 480.00, lastbuyprice_withDiscount = 480.00, meanbuyprice_withDiscount = 480.00
        , lastbuyprice_withTax = 480, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 480
                where sellbilldetailid = 549747;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16309, '2024-12-20', 9300, 7200, 7200
                    , 7200, 7200, 7200, 7200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 15, 0, 7200, 7200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9300, sellCostBuyPrice =sellCostBuyPrice+7200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+7200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+7200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+7200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+15
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 9300, 7200, 7200
                    , 7200, 7200, 7200, 7200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 7200, 7200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9300, sellCostBuyPrice =sellCostBuyPrice+7200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+7200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+7200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+7200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-9', userid = '75', storedetaildate = '2024-12-20 17:39:39' WHERE storedetailid = '16308';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16309', '1', '15', '1', '150455', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '-9', '75', '2024-12-20 17:39:39','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150455', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 17:39:39', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150455', '17', '10291', '1', '94', '94', '0', '', '1', '2024-12-20 17:39:39', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','94','94','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 78 where clientid = 10776;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 9414, 7200, 7200
                    , 7200, 7200, 7200, 7200
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,7200, 7200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9414, sellCostBuyPrice =sellCostBuyPrice+7200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+7200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+7200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+7200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10776, '2024-12-20', 9414, 7200, 7200
                    , 7200, 7200, 7200, 7200
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,7200, 7200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9414, sellCostBuyPrice =sellCostBuyPrice+7200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+7200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+7200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+7200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 9414, 7200, 7200
                    , 7200, 7200, 7200, 7200, 7200, 7200)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+9414, netSellCostBuyPrice = netSellCostBuyPrice+7200
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+7200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+7200
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+7200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+7200
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+7200
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+7200
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+7200;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658eb1a6cf8 and sellbillId = 150455 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:09:39";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:39:39", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:39:39', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:10:14";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:40:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:40:14', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658fad832f7
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:39:25', '067658fad832f7', '1', '0.00', '0', '0', '1', '220.00', '220', '220', '0', '1', '2024-12-20 17:40:14', '', '104', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','220','0','','0','0','220','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150456', '0', '2024-12-20 17:40:14', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '220', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 17:39:25','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36109;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('160','07269', '150456', '5', '16378', '1', '220', '220', '0', '', '1', '2024-12-20 17:40:14', '16378', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36109-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 160, lastbuyprice_withDiscountAndTax = 160
                where sellbilldetailid = 549750;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16378, '2024-12-20', 220, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 160, 160, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+160
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 160, 160, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+160
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '21', userid = '104', storedetaildate = '2024-12-20 17:40:14' WHERE storedetailid = '16377';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16378', '1', '1', '1', '150456', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '104', '2024-12-20 17:40:14','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7630',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7410','220', '0', '1', 'اضافة فاتورة مبيعات', '150456', '7630', '2024-12-20 17:40:14', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 220, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,160, 160, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+160
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,160, 160, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+160
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 220, 160, 160
                    , 160, 160, 160, 160, 160, 160)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+220, netSellCostBuyPrice = netSellCostBuyPrice+160
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+160
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+160
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+160
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+160
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+160
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+160
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+160;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658fad832f7 and sellbillId = 150456 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:10:15";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:40:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:40:15', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:13:07";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:43:07", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:43:07', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:13:14";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:43:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:43:14', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658fdf97c1d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:40:15', '067658fdf97c1d', '1', '0.00', '0', '0', '1', '880.00', '880', '880', '0', '1', '2024-12-20 17:43:14', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','880','0','','0','0','880','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150457', '0', '2024-12-20 17:43:14', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '880', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 17:40:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35802;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('190','06951', '150457', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-20 17:43:14', '15850', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35802-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 188, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 549751;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15850, '2024-12-20', 240, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 190, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+188
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 240, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+188
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '39', userid = '104', storedetaildate = '2024-12-20 17:43:14' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '150457', 'اضافة فاتورة مبيعات', 'sellbillController.php', '40', '39', '104', '2024-12-20 17:43:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36187;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','06958', '150457', '5', '15855', '1', '210', '210', '0', '', '1', '2024-12-20 17:43:14', '15855', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36187-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549752;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15855, '2024-12-20', 210, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '104', storedetaildate = '2024-12-20 17:43:14' WHERE storedetailid = '15854';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15855', '1', '1', '1', '150457', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '104', '2024-12-20 17:43:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35923;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07206', '150457', '5', '16300', '1', '200', '200', '0', '', '1', '2024-12-20 17:43:14', '16300', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35923-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549753;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16300, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '35', userid = '104', storedetaildate = '2024-12-20 17:43:14' WHERE storedetailid = '16299';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16300', '1', '1', '1', '150457', 'اضافة فاتورة مبيعات', 'sellbillController.php', '36', '35', '104', '2024-12-20 17:43:14','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:13:14";
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35651;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('165','16004', '150457', '5', '16004', '1', '230', '230', '0', '', '1', '2024-12-20 17:43:14', '16004', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35651-1,','1','1','0','0','230','230','0','','0','0.00','0','0','0','0');
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:43:14", deviceType = "DESKTOP" WHERE userid = 75;
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 164.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 164.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549754;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16004, '2024-12-20', 230, 165, 165
                    , 164, 165, 164, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+164
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+164
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+175
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 230, 165, 165
                    , 164, 165, 164, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+164
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+164
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+175
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-2', userid = '104', storedetaildate = '2024-12-20 17:43:14' WHERE storedetailid = '16003';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16004', '1', '1', '1', '150457', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-1', '-2', '104', '2024-12-20 17:43:14','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '8510',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7630','880', '0', '1', 'اضافة فاتورة مبيعات', '150457', '8510', '2024-12-20 17:43:14', '104',  'sellbillController.php','1','','0');
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:43:14', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');
UPDATE client SET  delegateid = 3 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 880, 640, 640
                    , 639, 640, 639, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,640, 628, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+880, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+639
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+639
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+640
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+628
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 880, 640, 640
                    , 639, 640, 639, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,640, 628, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+880, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+639
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+639
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+640
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+628
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 880, 640, 640
                    , 639, 640, 639, 650, 640, 628)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+880, netSellCostBuyPrice = netSellCostBuyPrice+640
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+640
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+639
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+640
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+639
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+650
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+640
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+628;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658fdf97c1d and sellbillId = 150457 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658c0fbd6c3
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1612,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:23:59', '067658c0fbd6c3', '1612', '0.00', '6212', '0', '1', '6212.00', '6212', '0', '6212', '1', '2024-12-20 17:43:14', '', '75', '0', 'محمد السعيد 73', '2', '1', '3', '90', 'محمد السعيد 73', '19' ,'0','','','','','-1','0','0','0','0','0','6212','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '6212', userid = '75' WHERE clientid = '1612';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1612','0.00','6212','0','اضافة فاتورة مبيعات','150458', '6212', '2024-12-20 17:43:14', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '6212', '0', null, '0', null, null,'', '0','1','1','6212','1','2024-12-20 17:23:59','0','0');
UPDATE client SET  inUse = 0 where clientid = 1612;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 36358;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('225','06603', '150458', '5', '15038', '3', '290', '870', '0', '', '1', '2024-12-20 17:43:14', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36358-3,','1','1','0','0','290','870','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 226.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 226.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 227, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549755;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15038, '2024-12-20', 870, 675, 675
                    , 678, 675, 678, 707.85
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 675, 681, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+870, sellCostBuyPrice =sellCostBuyPrice+675
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+675, sellCostMeanBuyPrice = sellCostMeanBuyPrice+678
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+675, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+678
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+707.85
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+675
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+681
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 870, 675, 675
                    , 678, 675, 678, 707.85
                    , 0, 0, 0, 0
                    , 0, 0, 0, 675, 681, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+870, sellCostBuyPrice =sellCostBuyPrice+675
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+675, sellCostMeanBuyPrice = sellCostMeanBuyPrice+678
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+675, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+678
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+707.85
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+675
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+681
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '41', userid = '75', storedetaildate = '2024-12-20 17:43:14' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '3', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '44', '41', '75', '2024-12-20 17:43:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35630;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35696;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','07108', '150458', '5', '16174', '2', '410', '820', '0', '', '1', '2024-12-20 17:43:15', '16174', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35630-1,35696-1,','1','1','0','0','410','820','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 350, lastbuyprice_withDiscountAndTax = 350
                where sellbilldetailid = 549756;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16174, '2024-12-20', 820, 700, 700
                    , 700, 700, 700, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 700, 700, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+820, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+700
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 820, 700, 700
                    , 700, 700, 700, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0, 700, 700, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+820, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+700
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '75', storedetaildate = '2024-12-20 17:43:15' WHERE storedetailid = '16173';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16174', '1', '2', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '10', '75', '2024-12-20 17:43:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36464;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('165','R3336', '150458', '1', '16417', '1', '200', '200', '0', '', '1', '2024-12-20 17:43:15', '16417', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36464-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 549757;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16417, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '75', storedetaildate = '2024-12-20 17:43:15' WHERE storedetailid = '16416';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16417', '1', '1', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-20 17:43:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35857;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('115','R3322', '150458', '1', '16265', '1', '165', '165', '0', '', '1', '2024-12-20 17:43:15', '16265', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35857-1,','1','1','0','0','165','165','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 115.00 , meanbuyprice = 115.00, lastbuyprice_withDiscount = 115.00, meanbuyprice_withDiscount = 115.00
        , lastbuyprice_withTax = 115, meanbuyprice_withTax = 115, lastbuyprice_withDiscountAndTax = 115
                where sellbilldetailid = 549758;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16265, '2024-12-20', 165, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 115, 115, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+115
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+115
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+115
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 165, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0, 115, 115, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+115
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+115
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+115
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '16', userid = '75', storedetaildate = '2024-12-20 17:43:15' WHERE storedetailid = '16264';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16265', '1', '1', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-20 17:43:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36390;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('265','07303', '150458', '5', '16452', '1', '330', '330', '0', '', '1', '2024-12-20 17:43:15', '16452', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36390-1,','1','1','0','0','330','330','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 265, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 549759;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16452, '2024-12-20', 330, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 330, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '21', userid = '75', storedetaildate = '2024-12-20 17:43:15' WHERE storedetailid = '16451';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16452', '1', '1', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '75', '2024-12-20 17:43:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36158;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('460','H1649', '150458', '14', '16394', '1', '550', '550', '0', '', '1', '2024-12-20 17:43:15', '16394', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36158-1,','1','1','0','0','550','550','0','','0','0.00','0','0','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:13:15";
UPDATE sellbilldetail SET  lastbuyprice = 460.00 , meanbuyprice = 460.00, lastbuyprice_withDiscount = 460.00, meanbuyprice_withDiscount = 460.00
        , lastbuyprice_withTax = 460, meanbuyprice_withTax = 460, lastbuyprice_withDiscountAndTax = 460
                where sellbilldetailid = 549760;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16394, '2024-12-20', 550, 460, 460
                    , 460, 460, 460, 460
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 460, 460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+460
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+460
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+460
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+460
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 550, 460, 460
                    , 460, 460, 460, 460
                    , 0, 0, 0, 0
                    , 0, 0, 0, 460, 460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+460
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+460
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+460
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+460
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '75', storedetaildate = '2024-12-20 17:43:15' WHERE storedetailid = '16393';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16394', '1', '1', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-20 17:43:15','0','0');
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:43:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:43:15', '104', 'editprint', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150457');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34926;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('420','H1465', '150458', '14', '15854', '1', '550', '550', '0', '', '1', '2024-12-20 17:43:15', '15854', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34926-1,','1','1','0','0','550','550','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 549761;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15854, '2024-12-20', 550, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 550, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+420
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-20 17:43:15' WHERE storedetailid = '15853';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15854', '1', '1', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-20 17:43:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35915;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('470','H1599', '150458', '14', '16217', '1', '580', '580', '0', '', '1', '2024-12-20 17:43:15', '16217', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35915-1,','1','1','0','0','580','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 470.00 , meanbuyprice = 470.00, lastbuyprice_withDiscount = 470.00, meanbuyprice_withDiscount = 470.00
        , lastbuyprice_withTax = 470, meanbuyprice_withTax = 470, lastbuyprice_withDiscountAndTax = 470
                where sellbilldetailid = 549762;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16217, '2024-12-20', 580, 470, 470
                    , 470, 470, 470, 470
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 470, 470, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+470
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+470, sellCostMeanBuyPrice = sellCostMeanBuyPrice+470
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+470, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+470
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+470
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+470
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+470
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 580, 470, 470
                    , 470, 470, 470, 470
                    , 0, 0, 0, 0
                    , 0, 0, 0, 470, 470, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+470
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+470, sellCostMeanBuyPrice = sellCostMeanBuyPrice+470
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+470, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+470
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+470
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+470
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+470
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '75', storedetaildate = '2024-12-20 17:43:15' WHERE storedetailid = '16216';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16217', '1', '1', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-20 17:43:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36187;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','06958', '150458', '5', '15855', '1', '210', '210', '0', '', '1', '2024-12-20 17:43:15', '15855', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36187-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549763;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15855, '2024-12-20', 210, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '19', userid = '75', storedetaildate = '2024-12-20 17:43:15' WHERE storedetailid = '15854';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15855', '1', '1', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '75', '2024-12-20 17:43:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36169;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('545','H1625', '150458', '14', '16280', '1', '635', '635', '0', '', '1', '2024-12-20 17:43:15', '16280', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36169-1,','1','1','0','0','635','635','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 545.00 , meanbuyprice = 543.00, lastbuyprice_withDiscount = 545.00, meanbuyprice_withDiscount = 543.00
        , lastbuyprice_withTax = 545, meanbuyprice_withTax = 449, lastbuyprice_withDiscountAndTax = 545
                where sellbilldetailid = 549764;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16280, '2024-12-20', 635, 545, 545
                    , 543, 545, 543, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 545, 449, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+635, sellCostBuyPrice =sellCostBuyPrice+545
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+545, sellCostMeanBuyPrice = sellCostMeanBuyPrice+543
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+545, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+543
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+449
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 635, 545, 545
                    , 543, 545, 543, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 545, 449, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+635, sellCostBuyPrice =sellCostBuyPrice+545
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+545, sellCostMeanBuyPrice = sellCostMeanBuyPrice+543
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+545, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+543
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+449
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '75', storedetaildate = '2024-12-20 17:43:15' WHERE storedetailid = '16279';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16280', '1', '1', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-20 17:43:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36120;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07232', '150458', '5', '16278', '1', '200', '200', '0', '', '1', '2024-12-20 17:43:15', '16278', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36120-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 148.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 148.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549765;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16278, '2024-12-20', 200, 155, 155
                    , 148, 155, 148, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+148
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+148
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 155, 155
                    , 148, 155, 148, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+148
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+148
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '19', userid = '75', storedetaildate = '2024-12-20 17:43:15' WHERE storedetailid = '16277';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16278', '1', '1', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '75', '2024-12-20 17:43:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35982;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('355','07234', '150458', '5', '16327', '2', '400', '800', '0', '', '1', '2024-12-20 17:43:15', '16327', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35982-2,','1','1','0','0','400','800','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 359.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 359.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 358, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549766;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16327, '2024-12-20', 800, 720, 720
                    , 718, 720, 718, 715
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 720, 716, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+720
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+720, sellCostMeanBuyPrice = sellCostMeanBuyPrice+718
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+720, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+718
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+715
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+720
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+716
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 800, 720, 720
                    , 718, 720, 718, 715
                    , 0, 0, 0, 0
                    , 0, 0, 0, 720, 716, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+720
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+720, sellCostMeanBuyPrice = sellCostMeanBuyPrice+718
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+720, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+718
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+715
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+720
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+716
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '18', userid = '75', storedetaildate = '2024-12-20 17:43:15' WHERE storedetailid = '16326';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16327', '1', '2', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '18', '75', '2024-12-20 17:43:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35933;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('170','07203', '150458', '5', '16308', '1', '220', '220', '0', '', '1', '2024-12-20 17:43:15', '16308', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35933-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 549767;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16308, '2024-12-20', 220, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 220, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '75', storedetaildate = '2024-12-20 17:43:15' WHERE storedetailid = '16307';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16308', '1', '1', '1', '150458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-20 17:43:15','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150458', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 17:43:15', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150458', '17', '10291', '1', '62', '62', '0', '', '1', '2024-12-20 17:43:15', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','62','62','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 90 where clientid = 1612;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 6212, 5005, 5005
                    , 4997, 5005, 4997, 5027.85
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,5005, 4896, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+6212, sellCostBuyPrice =sellCostBuyPrice+5005
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+5005, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4997
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+5005, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4997
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+5027.85
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+5005
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+4896
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1612, '2024-12-20', 6212, 5005, 5005
                    , 4997, 5005, 4997, 5027.85
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,5005, 4896, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+6212, sellCostBuyPrice =sellCostBuyPrice+5005
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+5005, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4997
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+5005, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4997
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+5027.85
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+5005
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+4896
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 6212, 5005, 5005
                    , 4997, 5005, 4997, 5027.85, 5005, 4896)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+6212, netSellCostBuyPrice = netSellCostBuyPrice+5005
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+5005
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+4997
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+5005
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+4997
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+5027.85
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+5005
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+4896;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658c0fbd6c3 and sellbillId = 150458 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:13:16";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 17:43:16", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:43:16', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:13:18";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:43:18", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:43:18', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:13:25";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:43:25", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:43:25', '101', 'showDetail', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150254');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:13:47";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:43:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 17:43:47', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:13:57";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:43:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 17:43:57', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=add');
BEGIN;
CALL supplierInUse(239,@supplierdebt,@suppliername,@dailyentryid,@treeIdis);
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('239', '10025.00', '3000', '1', 'ايصال دفع لمورد', '1', '7025', '2024-12-20 17:43:47', '104', 'supplierPayedDeptController.php', '', '0','1', '-1','1','1','3000','1','0','0','0','411');
UPDATE supplierdebtchange SET supplierid = '239', supplierdebtchangebefore = '10025.00', supplierdebtchangeamount = '3000', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '7025', supplierdebtchangedate = '2024-12-20 17:43:47', userid = '104', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='3000',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='10025',debtchangamountInSupplierCurrency='7025',debtchangafterInSupplierCurrency='7025', paySerialNo='411' WHERE supplierdebtchangeid = '26865';
UPDATE supplier SET  suppliercurrentDebt = '7025',suppliercurrentDebtInCurrency= '7025' , userid = '104', supplierdate = '2024-12-20 17:43:57'   WHERE supplierid = '239';
UPDATE supplier SET  inUse = 0 where supplierid = 239;
UPDATE save SET  savecurrentvalue = '5510',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8510.00','3000', '1', '1', 'ايصال دفع لمورد', '26865', '5510', '2024-12-20 17:43:57', '104',  'supplierPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '3000', '3000', '2024-12-20', '104', '0', '0', '2024-12-20 17:43:57','ايصال دفع لمورد ( B.T.M ) ','1','0','-1','0','26865','supplierReportsController.php?do=show&id=26865');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122332', '-1', '3000', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '3000', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122332', '-1', '3000', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-3000', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE supplierdebtchange SET supplierid = '239', supplierdebtchangebefore = '10025.00', supplierdebtchangeamount = '3000.00', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '7025.00', supplierdebtchangedate = '2024-12-20 17:43:47', userid = '104', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '122332',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='3000',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='10025',debtchangamountInSupplierCurrency='7025',debtchangafterInSupplierCurrency='7025', paySerialNo='411' WHERE supplierdebtchangeid = '26865';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:13:58";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:43:58", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 17:43:58', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:13:59";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:43:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 17:43:59', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:14:00";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:44:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 17:44:00', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:14:05";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:44:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 17:44:05', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:14:15";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:44:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:44:15', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:14:40";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:44:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:44:40', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:15:23";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:45:23", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:45:23', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:15:36";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:45:36", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:45:36', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:15:45";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:45:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:45:45', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:15:49";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 17:45:49", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:45:49', '101', 'editsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=145002');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:16:06";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:46:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 17:46:06', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:17:47";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:47:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 17:47:47', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:18:07";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:48:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 17:48:07', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:21:13";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:51:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:51:13', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765912984d77
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:45:45', '06765912984d77', '1', '0.00', '0', '0', '1', '720.00', '720', '720', '0', '1', '2024-12-20 17:51:13', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','720','0','','0','0','720','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150459', '0', '2024-12-20 17:51:13', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '720', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 17:45:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36362;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','0K807', '150459', '7', '16432', '1', '320', '320', '0', '', '1', '2024-12-20 17:51:13', '16432', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36362-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 549770;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16432, '2024-12-20', 320, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '26', userid = '104', storedetaildate = '2024-12-20 17:51:13' WHERE storedetailid = '16431';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16432', '1', '1', '1', '150459', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '26', '104', '2024-12-20 17:51:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36469;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('335','07221', '150459', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-20 17:51:13', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36469-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 549771;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16279, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '55', userid = '104', storedetaildate = '2024-12-20 17:51:13' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150459', 'اضافة فاتورة مبيعات', 'sellbillController.php', '56', '55', '104', '2024-12-20 17:51:13','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6230',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('5510','720', '0', '1', 'اضافة فاتورة مبيعات', '150459', '6230', '2024-12-20 17:51:13', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 720, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,585, 573, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+585
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+573
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 720, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,585, 573, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+585
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+585
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+573
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 720, 585, 585
                    , 585, 585, 585, 585, 585, 573)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+720, netSellCostBuyPrice = netSellCostBuyPrice+585
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+585
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+585
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+585
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+585
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+585
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+585
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+573;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765912984d77 and sellbillId = 150459 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:21:14";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:51:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:51:14', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:21:23";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:51:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 17:51:23', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:21:32";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:51:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 17:51:32', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:26:08";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:56:08", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 17:56:08', '77', '', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:26:25";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:56:25", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 17:56:25', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:26:37";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:56:37", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('saveController.php', '2024-12-20 17:56:37', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/saveController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:26:47";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:56:47", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 17:56:47', '77', '', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:26:59";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:56:59", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 17:56:59', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=add');
BEGIN;
INSERT INTO transfermoney (saveidfrom, saveidto, transfermoneyvalue, transfermoneydate, userid, conditions, dailyentryid , comment,currencyId,conversionFactor,conversionFactorFrom,conversionFactorTo,transfermoneyvalueInCurrency) VALUES ('5','1', '10000', '2024-12-20', '77', '0', '0','','1','1','0','0','10000');
UPDATE save SET  savecurrentvalue = '50000',  userid = '77' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('60000.00','10000', '1', '5', 'تحويل امول الى الخزنة  [ نقدي ] ', '3539', '50000', '2024-12-20 17:56:59', '77',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '16230',  userid = '77' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6230.00','10000', '0', '1', 'تحويل امول من الخزنة  [ جمعيه ] ', '3539', '16230', '2024-12-20 17:56:59', '77',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '5', saveidto = '1', transfermoneyvalue = '10000.00', transfermoneydate = '2024-12-20', userid = '77', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='10000' WHERE transfermoneyid = '3539';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:26:59";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:56:59", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 17:56:59', '77', 'sucess', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:27:01";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:57:01", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 17:57:01', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:27:38";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:57:38", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 17:57:38', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:27:46";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:57:46", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 17:57:46', '77', '', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:27:53";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 17:57:53", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 17:57:53', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:28:03";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:58:03", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:58:03', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:29:07";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 17:59:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:59:07', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:29:14";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:59:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:59:14', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765940b43359
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3998,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:58:03', '06765940b43359', '3998', '0.00', '303', '0', '1', '303.00', '303', '0', '303', '1', '2024-12-20 17:59:14', '', '104', '0', 'ام جون 41', '1', '1', '3', '95', 'ام جون 41', '2' ,'0','','','','','-1','0','0','0','0','0','303','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '303', userid = '104' WHERE clientid = '3998';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3998','0.00','303','0','اضافة فاتورة مبيعات','150460', '303', '2024-12-20 17:59:14', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '303', '0', null, '0', null, null,'', '0','1','1','303','1','2024-12-20 17:58:03','0','0');
UPDATE client SET  inUse = 0 where clientid = 3998;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36249;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','06861', '150460', '5', '15635', '1', '300', '300', '0', '', '1', '2024-12-20 17:59:14', '15635', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36249-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 241, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549772;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15635, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 236.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 241, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+236.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+241
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 240, 240
                    , 240, 240, 240, 236.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 241, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+236.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+241
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '104', storedetaildate = '2024-12-20 17:59:14' WHERE storedetailid = '15634';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15635', '1', '1', '1', '150460', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-20 17:59:14','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150460', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-20 17:59:14', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','3','3','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 95 where clientid = 3998;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 303, 240, 240
                    , 240, 240, 240, 236.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 241, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+303, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+236.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+241
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (3998, '2024-12-20', 303, 240, 240
                    , 240, 240, 240, 236.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 241, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+303, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+236.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+241
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 303, 240, 240
                    , 240, 240, 240, 236.67, 240, 241)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+303, netSellCostBuyPrice = netSellCostBuyPrice+240
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+240
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+240
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+240
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+240
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+236.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+240
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+241;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765940b43359 and sellbillId = 150460 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:29:15";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:59:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 17:59:15', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:29:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 17:59:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 17:59:27', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:29:46";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 17:59:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 17:59:46', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:30:08";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:00:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 18:00:08', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:30:18";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:00:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 18:00:18', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'كيمو', '', '100', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '16130',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('16230.00','100', '1', '1', 'إضافة مصروف', '25912', '16130', '2024-12-20 18:00:19', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كيمو', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25912';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:30:19";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:00:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 18:00:19', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:30:21";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:00:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 18:00:21', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:30:43";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:00:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:00:43', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:30:48";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:00:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 18:00:48', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:30:56";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:00:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 18:00:56', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:31:25";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:01:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 18:01:25', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:31:35";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:01:35", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:01:35', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248022
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1798,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '55' , clientdate = '2024-12-20 18:01:35', userid = '2' WHERE clientid = '1798';
UPDATE client SET  inUse = 0 where clientid = 1798;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1798','2500.00','2445','1','ايصال تحصيل (( قبض من عميل ))','248022', '55', '2024-12-20 16:57:59', '2', 'clientPayedDeptController.php', '   ', '2445', '0', null, '0', null, null,'', '-1','1','1','2445','1','','3667','0');
UPDATE save SET  savecurrentvalue = '155943.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('153498.50','2445', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248043', '155943.5', '2024-12-20 18:01:35', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '2445', '2445', '2024-12-20', '2', '0', '0', '2024-12-20 18:01:35','اضافة ايصال سداد للعميل اسماء السيد 43','1','0','0','0','248043','clientPayedDeptController.php?do=show&id=248043');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122333', '-1', '2445', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '2445', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122333', '-1', '2445', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-2445', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '1798', clientdebtchangebefore = '2500.000', clientdebtchangeamount = '2445.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248022', clientdebtchangeafter = '55.000', clientdebtchangedate = '2024-12-20 16:57:59', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '2445.00',discount='', reciptid='0', dailyentryid = '122333',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='2445',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248043';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248022 -clientdebtchangeId = 248043
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:31:36";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:01:36", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:01:36', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:31:43";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:01:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 18:01:43', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'كاميرات', '', '9000', '2024-12-20', '104', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '7130',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('16130.00','9000', '1', '1', 'إضافة مصروف', '25913', '7130', '2024-12-20 18:01:44', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كاميرات', expensesdetails = '', expensesValue = '9000.00', expensesdate = '2024-12-20', userid = '104', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25913';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:31:44";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:01:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 18:01:44', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:31:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:01:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 18:01:46', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:31:59";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:01:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 18:01:59', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:32:00";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:02:00", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:02:00', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:32:31";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:02:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:02:31', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:33:10";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:03:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-20 18:03:10', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:34:09";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:04:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-20 18:04:09', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =1798
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1798,@clientdebt,@clientname,@treeIdis);
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1798','55.00','055','1','تسوية عجز عميل بالخصم','-1', '0', '2024-12-20 18:04:09', '2', 'clientDeficitController.php', '', '55', '0', null, '0', null, null,'', '0','1','1','55','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20', userid = '2' WHERE clientid = '1798';
UPDATE client SET  inUse = 0 where clientid = 1798;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =1798 ,id=248044
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:34:09";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:04:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-20 18:04:09', '2', 'sucess', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:34:11";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:04:11", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-20 18:04:11', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:34:52";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:04:52", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:04:52', '77', '', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:35:07";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 18:05:07", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 18:05:07', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:35:09";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:05:09", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:05:09', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:35:16";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:05:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:05:16', '104', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:35:16";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 18:05:16", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 18:05:16', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676595178a053
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:02:31', '0676595178a053', '1', '0.00', '0', '0', '1', '603.00', '603', '603', '0', '1', '2024-12-20 18:05:16', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','603','0','','0','0','603','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150461', '0', '2024-12-20 18:05:16', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '603', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 18:02:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36008;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('425','H1640', '150461', '14', '16340', '1', '500', '500', '0', '', '1', '2024-12-20 18:05:16', '16340', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36008-1,','1','1','0','0','500','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 425.00 , meanbuyprice = 425.00, lastbuyprice_withDiscount = 425.00, meanbuyprice_withDiscount = 425.00
        , lastbuyprice_withTax = 425, meanbuyprice_withTax = 384, lastbuyprice_withDiscountAndTax = 425
                where sellbilldetailid = 549774;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16340, '2024-12-20', 500, 425, 425
                    , 425, 425, 425, 425
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 425, 384, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+425
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+425
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+425
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+425
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+384
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 500, 425, 425
                    , 425, 425, 425, 425
                    , 0, 0, 0, 0
                    , 0, 0, 0, 425, 384, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+425
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+425
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+425
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+425
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+384
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '30', userid = '104', storedetaildate = '2024-12-20 18:05:16' WHERE storedetailid = '16339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16340', '1', '1', '1', '150461', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31', '30', '104', '2024-12-20 18:05:16','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150461', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-20 18:05:16', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','3','3','0','','0','0.00','0','0','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31807;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('195','0K733', '150461', '7', '14297', '1', '100', '100', '0', '', '1', '2024-12-20 18:05:16', '14297', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31807-1,','1','1','0','0','100','100','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 228.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 228.00
        
                where sellbilldetailid = 549776;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14297, '2024-12-20', 100, 195, 195
                    , 228, 195, 228, 195
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+228
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+228
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+195
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 100, 195, 195
                    , 228, 195, 228, 195
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+228
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+228
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+195
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '104', storedetaildate = '2024-12-20 18:05:16' WHERE storedetailid = '14296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14297', '1', '1', '1', '150461', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-20 18:05:16','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7733',  userid = '104' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7130','603', '0', '1', 'اضافة فاتورة مبيعات', '150461', '7733', '2024-12-20 18:05:16', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 603, 620, 620
                    , 653, 620, 653, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,425, 384, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+603, sellCostBuyPrice =sellCostBuyPrice+620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+620, sellCostMeanBuyPrice = sellCostMeanBuyPrice+653
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+653
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+425
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+384
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 603, 620, 620
                    , 653, 620, 653, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,425, 384, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+603, sellCostBuyPrice =sellCostBuyPrice+620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+620, sellCostMeanBuyPrice = sellCostMeanBuyPrice+653
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+653
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+425
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+384
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 603, 620, 620
                    , 653, 620, 653, 620, 425, 384)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+603, netSellCostBuyPrice = netSellCostBuyPrice+620
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+620
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+653
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+620
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+653
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+620
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+425
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+384;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676595178a053 and sellbillId = 150461 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:35:17";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:05:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:05:17', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:35:21";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:05:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 18:05:21', '104', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:35:21";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:05:21", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:05:21', '77', 'details', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=details&id=13464');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:36:14";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:06:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 18:06:14', '104', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=add');
BEGIN;
INSERT INTO transfermoney (saveidfrom, saveidto, transfermoneyvalue, transfermoneydate, userid, conditions, dailyentryid , comment,currencyId,conversionFactor,conversionFactorFrom,conversionFactorTo,transfermoneyvalueInCurrency) VALUES ('1','2', '303', '2024-12-20', '104', '0', '0','','1','1','0','0','303');
UPDATE save SET  savecurrentvalue = '7430',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7733.00','303', '1', '1', 'تحويل امول الى الخزنة  [ فودافون كاش ] ', '3540', '7430', '2024-12-20 18:06:14', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '156246.5',  userid = '104' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('155943.50','303', '0', '2', 'تحويل امول من الخزنة  [ نقدي ] ', '3540', '156246.5', '2024-12-20 18:06:14', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '2', transfermoneyvalue = '303.00', transfermoneydate = '2024-12-20', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='303' WHERE transfermoneyid = '3540';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:36:14";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:06:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 18:06:14', '104', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:36:16";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:06:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 18:06:16', '104', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:36:20";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:06:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:06:20', '104', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:37:17";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:07:17", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:07:17', '77', '', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:37:35";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:07:35", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 18:07:35', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:37:40";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:07:40", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:07:40', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE userid = 104;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:37:57";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:07:57", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 18:07:57', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:37:58";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:38:00";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:08:00", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:08:00', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:38:33";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:08:33", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:08:33', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:39:18";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:09:18", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 18:09:18', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:39:37";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:09:37", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 18:09:37', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:39:41";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:09:41", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:09:41', '77', 'details', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=details&id=14149');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:40:54";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:10:54", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:10:54', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676596815b0d1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:08:33', '0676596815b0d1', '1', '0.00', '0', '0', '1', '1330.00', '1330', '1330', '0', '1', '2024-12-20 18:10:54', '', '9', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','1330','0','','0','0','1330','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150462', '0', '2024-12-20 18:10:54', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1330', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 18:08:33','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('735','H1335', '150462', '14', '15405', '1', '780', '780', '0', '', '1', '2024-12-20 18:10:54', '15405', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','780','780','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 735.00 , meanbuyprice = 704.00, lastbuyprice_withDiscount = 735.00, meanbuyprice_withDiscount = 704.00
        , lastbuyprice_withTax = 735, meanbuyprice_withTax = 599, lastbuyprice_withDiscountAndTax = 735
                where sellbilldetailid = 549777;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15405, '2024-12-20', 780, 735, 735
                    , 704, 735, 704, 690.83
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 735, 599, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+704
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+704
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+690.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+599
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 780, 735, 735
                    , 704, 735, 704, 690.83
                    , 0, 0, 0, 0
                    , 0, 0, 0, 735, 599, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+704
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+704
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+690.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+599
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '9', storedetaildate = '2024-12-20 18:10:54' WHERE storedetailid = '15404';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15405', '1', '1', '1', '150462', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '9', '2024-12-20 18:10:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35624;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('490','H1588', '150462', '14', '16168', '1', '550', '550', '0', '', '1', '2024-12-20 18:10:54', '16168', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35624-1,','1','1','0','0','550','550','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 490.00 , meanbuyprice = 490.00, lastbuyprice_withDiscount = 490.00, meanbuyprice_withDiscount = 490.00
        , lastbuyprice_withTax = 490, meanbuyprice_withTax = 490, lastbuyprice_withDiscountAndTax = 490
                where sellbilldetailid = 549778;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16168, '2024-12-20', 550, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 490, 490, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+490, sellCostMeanBuyPrice = sellCostMeanBuyPrice+490
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+490, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+490
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+490
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+490
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+490
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 550, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 490, 490, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+490, sellCostMeanBuyPrice = sellCostMeanBuyPrice+490
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+490, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+490
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+490
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+490
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+490
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '9', storedetaildate = '2024-12-20 18:10:54' WHERE storedetailid = '16167';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16168', '1', '1', '1', '150462', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '9', '2024-12-20 18:10:54','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '8760',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7430','1330', '0', '1', 'اضافة فاتورة مبيعات', '150462', '8760', '2024-12-20 18:10:54', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1330, 1225, 1225
                    , 1194, 1225, 1194, 1180.83
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1225, 1089, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1330, sellCostBuyPrice =sellCostBuyPrice+1225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1194
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1194
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1180.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1089
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1330, 1225, 1225
                    , 1194, 1225, 1194, 1180.83
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1225, 1089, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1330, sellCostBuyPrice =sellCostBuyPrice+1225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1194
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1194
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1180.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1089
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1330, 1225, 1225
                    , 1194, 1225, 1194, 1180.83, 1225, 1089)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1330, netSellCostBuyPrice = netSellCostBuyPrice+1225
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1225
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1194
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1225
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1194
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1180.83
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1225
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1089;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676596815b0d1 and sellbillId = 150462 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:40:55";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:10:55", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:10:55', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:41:08";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:11:08", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 18:11:08', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:41:17";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:11:17", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:11:17', '77', '', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:41:31";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:11:31", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:11:31', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:41:52";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 18:11:52", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 18:11:52', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:42:42";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:12:42", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:12:42', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:44:26";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:14:26", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 18:14:26', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:44:32";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:14:32", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 18:14:32', '77', '', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:44:42";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:14:42", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 18:14:42', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:44:49";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:14:49", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:14:49', '77', 'showDetail', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150001');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:45:24";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:15:24", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:15:24', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765977ae643d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:12:42', '06765977ae643d', '1', '0.00', '0', '10', '1', '960.00', '950', '950', '0', '1', '2024-12-20 18:15:24', '', '9', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','950','0','','0','0','950','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150463', '0', '2024-12-20 18:15:24', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '950', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 18:12:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36345;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('420','07295', '150463', '5', '16428', '2', '480', '960', '0', '', '1', '2024-12-20 18:15:24', '16428', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36345-2,','1','1','0','0','480','960','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 549779;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16428, '2024-12-20', 950, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 950, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '26', userid = '9', storedetaildate = '2024-12-20 18:15:24' WHERE storedetailid = '16427';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16428', '1', '2', '1', '150463', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '26', '9', '2024-12-20 18:15:24','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '9710',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8760','950', '0', '1', 'اضافة فاتورة مبيعات', '150463', '9710', '2024-12-20 18:15:25', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 97 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 950, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 950, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 950, 840, 840
                    , 840, 840, 840, 840, 840, 840)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+950, netSellCostBuyPrice = netSellCostBuyPrice+840
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+840
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+840
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+840
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+840
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+840
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+840
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+840;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765977ae643d and sellbillId = 150463 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:45:25";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:15:25", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:15:25', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:45:54";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:15:54", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:15:54', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:45:56";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:15:56", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:15:56', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:46:01";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:16:01", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-20 18:16:01', '77', 'showbarcode', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:46:52";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:16:52", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:16:52', '9', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248048
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10747,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '25' , clientdate = '2024-12-20 18:16:52', userid = '9' WHERE clientid = '10747';
UPDATE client SET  inUse = 0 where clientid = 10747;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10747','495.00','470','1','ايصال تحصيل (( قبض من عميل ))','248048', '25', '2024-12-20 18:15:56', '9', 'clientPayedDeptController.php', '   ', '470', '0', null, '0', null, null,'', '-1','1','1','470','1','','3668','0');
UPDATE save SET  savecurrentvalue = '10180',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('9710.00','470', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '248048', '10180', '2024-12-20 18:16:52', '9',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '470', '470', '2024-12-20', '9', '0', '0', '2024-12-20 18:16:53','اضافة ايصال سداد للعميل ام عدي يونس61','1','0','0','0','248048','clientPayedDeptController.php?do=show&id=248048');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122334', '-1', '470', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '470', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122334', '12569', '470', '','0');
UPDATE accountstree SET name = 'ام عدي يونس61', customName = 'ام عدي يونس61', customNameEn = 'ام عدي يونس61', nameEn = 'ام عدي يونس61', parent = '58', accountNature = '0', theValue = '-470', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '101', del = '0', sysdate = '2024-12-19 12:43:16' WHERE id = '12569';
UPDATE clientdebtchange SET clientid = '10747', clientdebtchangebefore = '495.000', clientdebtchangeamount = '470.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248048', clientdebtchangeafter = '25.000', clientdebtchangedate = '2024-12-20 18:15:56', userid = '9', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '470.00',discount='', reciptid='0', dailyentryid = '122334',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='470',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248048';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248048 -clientdebtchangeId = 248048
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:46:53";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:16:53", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:16:53', '9', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:46:55";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:16:55", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:16:55', '9', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:48:31";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:18:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 18:18:31', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:48:43";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:18:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 18:18:43', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:48:54";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:18:54", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:18:54', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:49:34";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:19:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:19:34', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149450');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:49:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:19:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:19:38', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149737');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:49:41";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:19:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:19:41', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150254');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('دنيا عبد المنعم 52' , '', '', '01091068866', '0', '', '0', '2024-12-20 18:21:10', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10777', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10777','0','0','0','إضافة عميل جديد','10777', '0', '2024-12-20 18:21:10', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('دنيا عبد المنعم 52', 'دنيا عبد المنعم 52', 'دنيا عبد المنعم 52', 'دنيا عبد المنعم 52', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-20 18:21:10');
UPDATE client SET clientname = 'دنيا عبد المنعم 52', clientaddress = '', clientphone = '', clientmobile = '01091068866', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '75'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12622',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10777';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:52:19";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:22:19", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:22:19', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067658fbbe5fd9
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10777,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:39:39', '067658fbbe5fd9', '10777', '0.00', '727', '0', '1', '727.00', '727', '0', '727', '1', '2024-12-20 18:22:19', '', '75', '0', 'دنيا عبد المنعم 52', '2', '1', '3', '98', 'دنيا عبد المنعم 52', '4' ,'0','','','','','-1','0','0','0','0','0','727','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '727', userid = '75' WHERE clientid = '10777';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10777','0.00','727','0','اضافة فاتورة مبيعات','150464', '727', '2024-12-20 18:22:19', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '727', '0', null, '0', null, null,'', '0','1','1','727','1','2024-12-20 17:39:39','0','0');
UPDATE client SET  inUse = 0 where clientid = 10777;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36128;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07264', '150464', '5', '16385', '1', '200', '200', '0', '', '1', '2024-12-20 18:22:19', '16385', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36128-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 120, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549780;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16385, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 120, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+120
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 120, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+120
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '19', userid = '75', storedetaildate = '2024-12-20 18:22:19' WHERE storedetailid = '16384';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16385', '1', '1', '1', '150464', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '75', '2024-12-20 18:22:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35983;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('405','H1628', '150464', '14', '16328', '1', '500', '500', '0', '', '1', '2024-12-20 18:22:20', '16328', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35983-1,','1','1','0','0','500','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 405.00 , meanbuyprice = 405.00, lastbuyprice_withDiscount = 405.00, meanbuyprice_withDiscount = 405.00
        , lastbuyprice_withTax = 405, meanbuyprice_withTax = 405, lastbuyprice_withDiscountAndTax = 405
                where sellbilldetailid = 549781;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16328, '2024-12-20', 500, 405, 405
                    , 405, 405, 405, 405
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 405, 405, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+405
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+405, sellCostMeanBuyPrice = sellCostMeanBuyPrice+405
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+405, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+405
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+405
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+405
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+405
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 500, 405, 405
                    , 405, 405, 405, 405
                    , 0, 0, 0, 0
                    , 0, 0, 0, 405, 405, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+405
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+405, sellCostMeanBuyPrice = sellCostMeanBuyPrice+405
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+405, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+405
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+405
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+405
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+405
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '75', storedetaildate = '2024-12-20 18:22:20' WHERE storedetailid = '16327';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16328', '1', '1', '1', '150464', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-20 18:22:20','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150464', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 18:22:20', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150464', '17', '10291', '1', '7', '7', '0', '', '1', '2024-12-20 18:22:20', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','7','7','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 98 where clientid = 10777;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 727, 545, 545
                    , 545, 545, 545, 545
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,545, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+727, sellCostBuyPrice =sellCostBuyPrice+545
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+545, sellCostMeanBuyPrice = sellCostMeanBuyPrice+545
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+545, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+545
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+545
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10777, '2024-12-20', 727, 545, 545
                    , 545, 545, 545, 545
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,545, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+727, sellCostBuyPrice =sellCostBuyPrice+545
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+545, sellCostMeanBuyPrice = sellCostMeanBuyPrice+545
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+545, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+545
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+545
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 727, 545, 545
                    , 545, 545, 545, 545, 545, 525)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+727, netSellCostBuyPrice = netSellCostBuyPrice+545
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+545
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+545
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+545
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+545
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+545
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+545
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+525;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067658fbbe5fd9 and sellbillId = 150464 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:52:20";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:22:20", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:22:20', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:53:47";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:23:47", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:23:47', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676598ee3b401
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:18:54', '0676598ee3b401', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-20 18:23:47', '', '9', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','300','0','','0','0','300','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150465', '0', '2024-12-20 18:23:47', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 18:18:54','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('285','0K781', '150465', '7', '15694', '1', '300', '300', '0', '', '1', '2024-12-20 18:23:47', '15694', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 285.00 , meanbuyprice = 281.00, lastbuyprice_withDiscount = 285.00, meanbuyprice_withDiscount = 281.00
        , lastbuyprice_withTax = 285, meanbuyprice_withTax = 280, lastbuyprice_withDiscountAndTax = 285
                where sellbilldetailid = 549784;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15694, '2024-12-20', 300, 285, 285
                    , 281, 285, 281, 280.38
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 285, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+281
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+281
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280.38
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 285, 285
                    , 281, 285, 281, 280.38
                    , 0, 0, 0, 0
                    , 0, 0, 0, 285, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+281
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+281
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280.38
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '9', storedetaildate = '2024-12-20 18:23:47' WHERE storedetailid = '15693';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15694', '1', '1', '1', '150465', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '9', '2024-12-20 18:23:47','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '10480',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('10180','300', '0', '1', 'اضافة فاتورة مبيعات', '150465', '10480', '2024-12-20 18:23:47', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 300, 285, 285
                    , 281, 285, 281, 280.38
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,285, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+281
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+281
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280.38
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 285, 285
                    , 281, 285, 281, 280.38
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,285, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+281
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+281
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280.38
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 300, 285, 285
                    , 281, 285, 281, 280.38, 285, 280)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+285
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+285
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+281
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+285
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+281
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+280.38
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+285
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+280;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676598ee3b401 and sellbillId = 150465 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:53:48";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:23:48", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:23:48', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:53:49";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:23:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:23:49', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:54:00";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 18:24:00", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:24:00', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:54:12";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:24:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:24:12', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:54:53";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:24:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:24:53', '2', 'delete', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=delete&sellbillid=149450&action=');

-- ----------------------------------------------------------------------------------------------------
-- bill delete start - sellbill with id = 149450
-- ----------------------------------------------------------------------------------------------------

BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149450;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 18:24:53', userid = '101',delbyuserid = '2', conditions = '1'  ,billReservation= 0,billReservationDate='0000-00-00'  WHERE sellbillid = '149450';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 29022;
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 1560.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 1560.00
        
                where sellbilldetailid = 546031;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12941, '2024-12-20', 250, 240, 240
                    , 1560, 240, 1560, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-250, sellCostBuyPrice =sellCostBuyPrice-240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-240, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1560
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1560
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 250, 240, 240
                    , 1560, 240, 1560, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-250, sellCostBuyPrice =sellCostBuyPrice-240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-240, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1560
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1560
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-6', userid = '2', storedetaildate = '2024-12-20 18:24:53' WHERE storedetailid = '12940';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12941', '1', '1', '0', '149450', 'حذف فاتورة مبيعات', 'sellbillController.php', '-7', '-6', '2', '2024-12-20 18:24:53','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        
                where sellbilldetailid = 546032;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15283, '2024-12-20', 215, 280, 280
                    , 280, 280, 280, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-215, sellCostBuyPrice =sellCostBuyPrice-280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-280, sellCostMeanBuyPrice = sellCostMeanBuyPrice-280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 215, 280, 280
                    , 280, 280, 280, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-215, sellCostBuyPrice =sellCostBuyPrice-280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-280, sellCostMeanBuyPrice = sellCostMeanBuyPrice-280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-6', userid = '2', storedetaildate = '2024-12-20 18:24:53' WHERE storedetailid = '15282';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15283', '1', '1', '0', '149450', 'حذف فاتورة مبيعات', 'sellbillController.php', '-7', '-6', '2', '2024-12-20 18:24:53','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 495.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 495.00
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 71, lastbuyprice_withDiscountAndTax = 495
                where sellbilldetailid = 546033;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14340, '2024-12-20', 420, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 495, 71, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-495, sellCostMeanBuyPrice = sellCostMeanBuyPrice-495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-71
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 71, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-495, sellCostMeanBuyPrice = sellCostMeanBuyPrice-495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-71
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-14', userid = '2', storedetaildate = '2024-12-20 18:24:53' WHERE storedetailid = '14339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14340', '1', '1', '0', '149450', 'حذف فاتورة مبيعات', 'sellbillController.php', '-15', '-14', '2', '2024-12-20 18:24:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 22469;
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
        
                where sellbilldetailid = 546034;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10242, '2024-12-20', 155, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-155, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-155, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '2', userid = '2', storedetaildate = '2024-12-20 18:24:53' WHERE storedetailid = '10241';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10242', '1', '1', '0', '149450', 'حذف فاتورة مبيعات', 'sellbillController.php', '1', '2', '2', '2024-12-20 18:24:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36346;
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 546037;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16223, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-470, sellCostBuyPrice =sellCostBuyPrice-400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-400, sellCostMeanBuyPrice = sellCostMeanBuyPrice-400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-400
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-470, sellCostBuyPrice =sellCostBuyPrice-400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-400, sellCostMeanBuyPrice = sellCostMeanBuyPrice-400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-400
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '12', userid = '2', storedetaildate = '2024-12-20 18:24:53' WHERE storedetailid = '16222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16223', '1', '1', '0', '149450', 'حذف فاتورة مبيعات', 'sellbillController.php', '11', '12', '2', '2024-12-20 18:24:53','0','0');
CALL clientInUse(4241,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '769', userid = '2' WHERE clientid = '4241';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4241','2314.00','1545.00','1','حذف فاتورة مبيعات','149450', '769', '2024-12-20 18:24:53', '2', 'sellbillController.php', 'حذف فاتورة مبيعات', '1545', '0', null, '0', null, null,'', '0','1','1','1545','1','2024-12-13 18:00:14','0','0');
UPDATE client SET  inUse = 0 where clientid = 4241;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1545, 1635, 1635
                    , 2955, 1635, 2955, 1355
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,895, 471, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1545, sellCostBuyPrice =sellCostBuyPrice-1635
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1635, sellCostMeanBuyPrice = sellCostMeanBuyPrice-2955
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1635, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-2955
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1355
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-895
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-471
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4241, '2024-12-20', 1545, 1635, 1635
                    , 2955, 1635, 2955, 1355
                    , 0, 0, 0, 0
                    , 0, 0, 0, 895, 471, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1545, sellCostBuyPrice =sellCostBuyPrice-1635
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1635, sellCostMeanBuyPrice = sellCostMeanBuyPrice-2955
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1635, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-2955
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1355
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-895
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-471
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1545, 1635, 1635
                    , 2955, 1635, 2955, 1355, 895, 471)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-1545, netSellCostBuyPrice = netSellCostBuyPrice-1635
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-1635
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-2955
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-1635
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-2955
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-1355
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-895
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-471;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill delete end - sellbill with id = 149450
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:54:53";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:24:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:24:53', '2', 'sucess', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:54:55";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:24:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:24:55', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:55:03";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:25:03", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:25:03', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676599bd2cbf0
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1834,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:22:21', '0676599bd2cbf0', '1834', '-22.00', '276', '0', '1', '298.00', '298', '0', '298', '1', '2024-12-20 18:25:03', '', '75', '0', 'وفاء الموجي d103', '2', '1', '3', '80', 'وفاء الموجي d103', '3' ,'0','','','','','-1','0','0','0','0','0','298','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '276', userid = '75' WHERE clientid = '1834';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1834','-22.00','298','0','اضافة فاتورة مبيعات','150466', '276', '2024-12-20 18:25:03', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '298', '0', null, '0', null, null,'', '0','1','1','298','1','2024-12-20 18:22:21','0','0');
UPDATE client SET  inUse = 0 where clientid = 1834;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35616;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('215','0K789', '150466', '7', '15760', '1', '275', '275', '0', '', '1', '2024-12-20 18:25:03', '15760', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35616-1,','1','1','0','0','275','275','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 215.00 , meanbuyprice = 215.00, lastbuyprice_withDiscount = 215.00, meanbuyprice_withDiscount = 215.00
        , lastbuyprice_withTax = 215, meanbuyprice_withTax = 215, lastbuyprice_withDiscountAndTax = 215
                where sellbilldetailid = 549785;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15760, '2024-12-20', 275, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 215, 215, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+215
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 275, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 215, 215, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+215
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '75', storedetaildate = '2024-12-20 18:25:03' WHERE storedetailid = '15759';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15760', '1', '1', '1', '150466', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '75', '2024-12-20 18:25:03','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150466', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 18:25:03', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150466', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-20 18:25:04', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','3','3','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 80 where clientid = 1834;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 298, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,215, 215, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+298, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+215
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1834, '2024-12-20', 298, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,215, 215, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+298, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+215
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 298, 215, 215
                    , 215, 215, 215, 215, 215, 215)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+298, netSellCostBuyPrice = netSellCostBuyPrice+215
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+215
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+215
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+215
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+215
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+215
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+215
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+215;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676599bd2cbf0 and sellbillId = 150466 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:55:04";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:25:04", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:25:04', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:55:08";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:25:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:25:08', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:55:18";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:25:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:25:18', '2', 'delete', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=delete&sellbillid=149737&action=');

-- ----------------------------------------------------------------------------------------------------
-- bill delete start - sellbill with id = 149737
-- ----------------------------------------------------------------------------------------------------

BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149737;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 18:25:18', userid = '101',delbyuserid = '2', conditions = '1'  ,billReservation= 0,billReservationDate='0000-00-00'  WHERE sellbillid = '149737';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 29854;
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 565.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 565.00
        
                where sellbilldetailid = 546920;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13153, '2024-12-20', 310, 260, 260
                    , 565, 260, 565, 259.47
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-310, sellCostBuyPrice =sellCostBuyPrice-260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-260, sellCostMeanBuyPrice = sellCostMeanBuyPrice-565
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-565
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-259.47
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 310, 260, 260
                    , 565, 260, 565, 259.47
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-310, sellCostBuyPrice =sellCostBuyPrice-260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-260, sellCostMeanBuyPrice = sellCostMeanBuyPrice-565
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-565
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-259.47
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '37', userid = '2', storedetaildate = '2024-12-20 18:25:18' WHERE storedetailid = '13152';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13153', '1', '1', '0', '149737', 'حذف فاتورة مبيعات', 'sellbillController.php', '36', '37', '2', '2024-12-20 18:25:18','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        
                where sellbilldetailid = 546921;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15283, '2024-12-20', 265, 280, 280
                    , 280, 280, 280, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-265, sellCostBuyPrice =sellCostBuyPrice-280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-280, sellCostMeanBuyPrice = sellCostMeanBuyPrice-280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 265, 280, 280
                    , 280, 280, 280, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-265, sellCostBuyPrice =sellCostBuyPrice-280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-280, sellCostMeanBuyPrice = sellCostMeanBuyPrice-280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-5', userid = '2', storedetaildate = '2024-12-20 18:25:18' WHERE storedetailid = '15282';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15283', '1', '1', '0', '149737', 'حذف فاتورة مبيعات', 'sellbillController.php', '-6', '-5', '2', '2024-12-20 18:25:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36346;
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 546922;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16223, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-470, sellCostBuyPrice =sellCostBuyPrice-400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-400, sellCostMeanBuyPrice = sellCostMeanBuyPrice-400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-400
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-470, sellCostBuyPrice =sellCostBuyPrice-400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-400, sellCostMeanBuyPrice = sellCostMeanBuyPrice-400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-400
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '13', userid = '2', storedetaildate = '2024-12-20 18:25:18' WHERE storedetailid = '16222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16223', '1', '1', '0', '149737', 'حذف فاتورة مبيعات', 'sellbillController.php', '12', '13', '2', '2024-12-20 18:25:18','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
        
                where sellbilldetailid = 546923;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10242, '2024-12-20', 155, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-155, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-155, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '3', userid = '2', storedetaildate = '2024-12-20 18:25:18' WHERE storedetailid = '10241';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10242', '1', '1', '0', '149737', 'حذف فاتورة مبيعات', 'sellbillController.php', '2', '3', '2', '2024-12-20 18:25:18','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 495.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 495.00
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 71, lastbuyprice_withDiscountAndTax = 495
                where sellbilldetailid = 546924;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14340, '2024-12-20', 420, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 495, 71, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-495, sellCostMeanBuyPrice = sellCostMeanBuyPrice-495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-71
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 71, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-495, sellCostMeanBuyPrice = sellCostMeanBuyPrice-495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-71
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-13', userid = '2', storedetaildate = '2024-12-20 18:25:18' WHERE storedetailid = '14339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14340', '1', '1', '0', '149737', 'حذف فاتورة مبيعات', 'sellbillController.php', '-14', '-13', '2', '2024-12-20 18:25:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 29022;
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 1560.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 1560.00
        
                where sellbilldetailid = 546925;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12941, '2024-12-20', 250, 240, 240
                    , 1560, 240, 1560, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-250, sellCostBuyPrice =sellCostBuyPrice-240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-240, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1560
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1560
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 250, 240, 240
                    , 1560, 240, 1560, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-250, sellCostBuyPrice =sellCostBuyPrice-240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-240, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1560
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1560
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-5', userid = '2', storedetaildate = '2024-12-20 18:25:18' WHERE storedetailid = '12940';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12941', '1', '1', '0', '149737', 'حذف فاتورة مبيعات', 'sellbillController.php', '-6', '-5', '2', '2024-12-20 18:25:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35973;
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 1105.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 1105.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 1710, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 546926;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16204, '2024-12-20', 610, 500, 500
                    , 1105, 500, 1105, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 500, 1710, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-610, sellCostBuyPrice =sellCostBuyPrice-500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1105
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1105
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1710
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 500, 500
                    , 1105, 500, 1105, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 1710, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-610, sellCostBuyPrice =sellCostBuyPrice-500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1105
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1105
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1710
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-1', userid = '2', storedetaildate = '2024-12-20 18:25:18' WHERE storedetailid = '16203';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16204', '1', '1', '0', '149737', 'حذف فاتورة مبيعات', 'sellbillController.php', '-2', '-1', '2', '2024-12-20 18:25:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36103;
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 231.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 231.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 238, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 546929;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16374, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-300, sellCostBuyPrice =sellCostBuyPrice-225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-225, sellCostMeanBuyPrice = sellCostMeanBuyPrice-231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-238
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-300, sellCostBuyPrice =sellCostBuyPrice-225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-225, sellCostMeanBuyPrice = sellCostMeanBuyPrice-231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-238
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '12', userid = '2', storedetaildate = '2024-12-20 18:25:18' WHERE storedetailid = '16373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16374', '1', '1', '0', '149737', 'حذف فاتورة مبيعات', 'sellbillController.php', '11', '12', '2', '2024-12-20 18:25:18','0','0');
CALL clientInUse(4241,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-2059', userid = '2' WHERE clientid = '4241';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4241','769.00','2828.00','1','حذف فاتورة مبيعات','149737', '-2059', '2024-12-20 18:25:18', '2', 'sellbillController.php', 'حذف فاتورة مبيعات', '2828', '0', null, '0', null, null,'', '0','1','1','2828','1','2024-12-16 16:54:28','0','0');
UPDATE client SET  inUse = 0 where clientid = 4241;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2828, 2620, 2620
                    , 4856, 2620, 4856, 2351.97
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1620, 2419, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-2828, sellCostBuyPrice =sellCostBuyPrice-2620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-2620, sellCostMeanBuyPrice = sellCostMeanBuyPrice-4856
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-2620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-4856
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-2351.97
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1620
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-2419
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4241, '2024-12-20', 2828, 2620, 2620
                    , 4856, 2620, 4856, 2351.97
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1620, 2419, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-2828, sellCostBuyPrice =sellCostBuyPrice-2620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-2620, sellCostMeanBuyPrice = sellCostMeanBuyPrice-4856
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-2620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-4856
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-2351.97
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1620
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-2419
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2828, 2620, 2620
                    , 4856, 2620, 4856, 2351.97, 1620, 2419)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-2828, netSellCostBuyPrice = netSellCostBuyPrice-2620
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-2620
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-4856
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-2620
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-4856
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-2351.97
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-1620
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-2419;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill delete end - sellbill with id = 149737
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:55:18";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:25:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:25:18', '2', 'sucess', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:55:20";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:25:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:25:20', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:55:33";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:25:33", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:25:33', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:55:41";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:25:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:25:41', '2', 'delete', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=delete&sellbillid=150254&action=0');

-- ----------------------------------------------------------------------------------------------------
-- bill delete start - sellbill with id = 150254
-- ----------------------------------------------------------------------------------------------------

BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150254;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 18:25:41', userid = '101',delbyuserid = '2', conditions = '1'  ,billReservation= 0,billReservationDate='0000-00-00'  WHERE sellbillid = '150254';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35977;
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 503.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 503.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 507, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 548976;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16297, '2024-12-20', 580, 500, 500
                    , 503, 500, 503, 507.69
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 500, 507, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-580, sellCostBuyPrice =sellCostBuyPrice-500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-507.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-507
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 580, 500, 500
                    , 503, 500, 503, 507.69
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 507, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-580, sellCostBuyPrice =sellCostBuyPrice-500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-507.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-507
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '133', userid = '2', storedetaildate = '2024-12-20 18:25:41' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '0', '150254', 'حذف فاتورة مبيعات', 'sellbillController.php', '132', '133', '2', '2024-12-20 18:25:41','0','0');
CALL clientInUse(4241,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-2645', userid = '2' WHERE clientid = '4241';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4241','-2059.00','586.00','1','حذف فاتورة مبيعات','150254', '-2645', '2024-12-20 18:25:41', '2', 'sellbillController.php', 'حذف فاتورة مبيعات', '586', '0', null, '0', null, null,'', '0','1','1','586','1','2024-12-19 15:39:21','0','0');
UPDATE client SET  inUse = 0 where clientid = 4241;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 586, 500, 500
                    , 503, 500, 503, 507.69
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,500, 507, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-586, sellCostBuyPrice =sellCostBuyPrice-500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-507.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-507
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4241, '2024-12-20', 586, 500, 500
                    , 503, 500, 503, 507.69
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 507, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-586, sellCostBuyPrice =sellCostBuyPrice-500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-507.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-507
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 586, 500, 500
                    , 503, 500, 503, 507.69, 500, 507)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-586, netSellCostBuyPrice = netSellCostBuyPrice-500
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-500
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-503
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-500
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-503
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-507.69
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-500
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-507;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill delete end - sellbill with id = 150254
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:55:41";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:25:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:25:41', '2', 'sucess', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:55:43";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:25:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:25:43', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:56:12";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:26:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 18:26:12', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:56:44";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 18:26:44", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:26:44', '101', 'editsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=145002');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:56:54";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:26:54", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:26:54', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248044
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6151,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '1' , clientdate = '2024-12-20 18:26:54', userid = '2' WHERE clientid = '6151';
UPDATE client SET  inUse = 0 where clientid = 6151;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6151','2006.00','2005','1','ايصال تحصيل (( قبض من عميل ))','248044', '1', '2024-12-20 18:01:36', '2', 'clientPayedDeptController.php', '   ', '2005', '0', null, '0', null, null,'', '-1','1','1','2005','1','','3668','0');
UPDATE save SET  savecurrentvalue = '158251.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('156246.50','2005', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248056', '158251.5', '2024-12-20 18:26:54', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('مروة الليثي I888', 'مروة الليثي I888', 'مروة الليثي I888', 'مروة الليثي I888', '58', '0', '1.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 18:26:55');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '2005', '2005', '2024-12-20', '2', '0', '0', '2024-12-20 18:26:55','اضافة ايصال سداد للعميل مروة الليثي I888','1','0','0','0','248056','clientPayedDeptController.php?do=show&id=248056');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122335', '-1', '2005', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '2005', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122335', '12623', '2005', '','0');
UPDATE accountstree SET name = 'مروة الليثي I888', customName = 'مروة الليثي I888', customNameEn = 'مروة الليثي I888', nameEn = 'مروة الليثي I888', parent = '58', accountNature = '0', theValue = '-2004', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 18:26:55' WHERE id = '12623';
UPDATE clientdebtchange SET clientid = '6151', clientdebtchangebefore = '2006.000', clientdebtchangeamount = '2005.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248044', clientdebtchangeafter = '1.000', clientdebtchangedate = '2024-12-20 18:01:36', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '2005.00',discount='', reciptid='0', dailyentryid = '122335',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='2005',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248056';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248044 -clientdebtchangeId = 248056
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:56:55";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:26:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:26:55', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:57:15";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:27:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:27:15', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248057
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7546,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 18:27:15', userid = '2' WHERE clientid = '7546';
UPDATE client SET  inUse = 0 where clientid = 7546;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7546','313.00','313','1','ايصال تحصيل (( قبض من عميل ))','248057', '0', '2024-12-20 18:26:56', '2', 'clientPayedDeptController.php', '   ', '313', '0', null, '0', null, null,'', '-1','1','1','313','1','','3669','0');
UPDATE save SET  savecurrentvalue = '158564.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('158251.50','313', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248057', '158564.5', '2024-12-20 18:27:15', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '313', '313', '2024-12-20', '2', '0', '0', '2024-12-20 18:27:16','اضافة ايصال سداد للعميل ابرار محمد G321','1','0','0','0','248057','clientPayedDeptController.php?do=show&id=248057');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122336', '-1', '313', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '313', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122336', '-1', '313', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-313', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '7546', clientdebtchangebefore = '313.000', clientdebtchangeamount = '313.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248057', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 18:26:56', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '313.00',discount='', reciptid='0', dailyentryid = '122336',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='313',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248057';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248057 -clientdebtchangeId = 248057
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:57:16";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:27:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:27:16', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('ايمان سعيد 25 م' , '', '', '0121444072', '0', '', '0', '2024-12-20 18:27:24', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10778', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10778','0','0','0','إضافة عميل جديد','10778', '0', '2024-12-20 18:27:24', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('ايمان سعيد 25 م', 'ايمان سعيد 25 م', 'ايمان سعيد 25 م', 'ايمان سعيد 25 م', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-20 18:27:24');
UPDATE client SET clientname = 'ايمان سعيد 25 م', clientaddress = '', clientphone = '', clientmobile = '0121444072', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '75'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12624',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10778';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:57:55";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:27:55", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:27:55', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659a60b9377
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10778,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:25:04', '067659a60b9377', '10778', '0.00', '384', '0', '1', '384.00', '384', '0', '384', '1', '2024-12-20 18:27:55', '', '75', '0', 'ايمان سعيد 25 م', '2', '1', '3', '78', 'ايمان سعيد 25 م', '3' ,'0','','','','','-1','0','0','0','0','0','384','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '384', userid = '75' WHERE clientid = '10778';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10778','0.00','384','0','اضافة فاتورة مبيعات','150467', '384', '2024-12-20 18:27:55', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '384', '0', null, '0', null, null,'', '0','1','1','384','1','2024-12-20 18:25:04','0','0');
UPDATE client SET  inUse = 0 where clientid = 10778;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35790;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('295','78808', '150467', '5', '15674', '1', '360', '360', '0', '', '1', '2024-12-20 18:27:55', '15674', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35790-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 295.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 295.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295
                where sellbilldetailid = 549788;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15674, '2024-12-20', 360, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '27', userid = '75', storedetaildate = '2024-12-20 18:27:55' WHERE storedetailid = '15673';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15674', '1', '1', '1', '150467', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '27', '75', '2024-12-20 18:27:55','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150467', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 18:27:55', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150467', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-20 18:27:55', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','4','4','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 78 where clientid = 10778;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 384, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+384, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10778, '2024-12-20', 384, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+384, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 384, 295, 295
                    , 295, 295, 295, 295, 295, 295)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+384, netSellCostBuyPrice = netSellCostBuyPrice+295
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+295
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+295
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+295
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+295
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+295
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+295
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+295;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659a60b9377 and sellbillId = 150467 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:57:55";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:27:55", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:27:55', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:57:56";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:27:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:27:56', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248058
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3108,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '2205' , clientdate = '2024-12-20 18:27:56', userid = '2' WHERE clientid = '3108';
UPDATE client SET  inUse = 0 where clientid = 3108;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3108','3624.00','1419','1','ايصال تحصيل (( قبض من عميل ))','248058', '2205', '2024-12-20 18:27:16', '2', 'clientPayedDeptController.php', '   ', '1419', '0', null, '0', null, null,'', '-1','1','1','1419','1','','3670','0');
UPDATE save SET  savecurrentvalue = '159983.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('158564.50','1419', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248060', '159983.5', '2024-12-20 18:27:56', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1419', '1419', '2024-12-20', '2', '0', '0', '2024-12-20 18:27:56','اضافة ايصال سداد للعميل ام حمزة الاسماعلية Z19','1','0','0','0','248060','clientPayedDeptController.php?do=show&id=248060');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122337', '-1', '1419', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1419', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122337', '-1', '1419', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1419', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '3108', clientdebtchangebefore = '3624.000', clientdebtchangeamount = '1419.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248058', clientdebtchangeafter = '2205.000', clientdebtchangedate = '2024-12-20 18:27:16', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1419.00',discount='', reciptid='0', dailyentryid = '122337',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1419',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248060';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248058 -clientdebtchangeId = 248060
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:57:56";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:27:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:27:56', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:58:14";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 18:28:14", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:28:14', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659a205196b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3202,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:24:00', '067659a205196b', '3202', '0.00', '990', '0', '1', '990.00', '990', '0', '990', '1', '2024-12-20 18:28:14', '', '101', '0', 'ايمان عبد الحميد P183', '2', '1', '3', '79', 'ايمان عبد الحميد P183', '5' ,'0','','','','','-1','0','0','0','0','0','990','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '990', userid = '101' WHERE clientid = '3202';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3202','0.00','990','0','اضافة فاتورة مبيعات','150468', '990', '2024-12-20 18:28:14', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '990', '0', null, '0', null, null,'', '0','1','1','990','1','2024-12-20 18:24:00','0','0');
UPDATE client SET  inUse = 0 where clientid = 3202;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36319;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('330','07291', '150468', '5', '16416', '2', '380', '760', '0', '', '1', '2024-12-20 18:28:14', '16416', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36319-2,','1','1','0','0','380','760','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
        , lastbuyprice_withTax = 330, meanbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 330
                where sellbilldetailid = 549791;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16416, '2024-12-20', 760, 660, 660
                    , 660, 660, 660, 660
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 660, 660, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+760, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+660
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+660
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+660
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 760, 660, 660
                    , 660, 660, 660, 660
                    , 0, 0, 0, 0
                    , 0, 0, 0, 660, 660, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+760, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+660
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+660
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+660
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '101', storedetaildate = '2024-12-20 18:28:14' WHERE storedetailid = '16415';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16416', '1', '2', '1', '150468', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '3', '101', '2024-12-20 18:28:14','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','07293', '150468', '5', '16434', '1', '200', '200', '0', '', '1', '2024-12-20 18:28:14', '16434', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 549792;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16434, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-2', userid = '101', storedetaildate = '2024-12-20 18:28:14' WHERE storedetailid = '16433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16434', '1', '1', '1', '150468', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-1', '-2', '101', '2024-12-20 18:28:14','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150468', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 18:28:14', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150468', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-20 18:28:14', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','10','10','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 79 where clientid = 3202;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 990, 805, 805
                    , 805, 805, 805, 805
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,805, 805, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+990, sellCostBuyPrice =sellCostBuyPrice+805
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+805, sellCostMeanBuyPrice = sellCostMeanBuyPrice+805
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+805, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+805
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+805
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+805
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+805
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (3202, '2024-12-20', 990, 805, 805
                    , 805, 805, 805, 805
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,805, 805, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+990, sellCostBuyPrice =sellCostBuyPrice+805
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+805, sellCostMeanBuyPrice = sellCostMeanBuyPrice+805
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+805, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+805
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+805
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+805
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+805
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 990, 805, 805
                    , 805, 805, 805, 805, 805, 805)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+990, netSellCostBuyPrice = netSellCostBuyPrice+805
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+805
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+805
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+805
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+805
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+805
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+805
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+805;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659a205196b and sellbillId = 150468 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:58:15";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 18:28:15", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:28:15', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:58:36";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:28:36", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:28:36', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:59:01";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:29:01", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:29:01', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659b0c076b8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(97,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:27:56', '067659b0c076b8', '97', '0.00', '455', '0', '1', '455.00', '455', '0', '455', '1', '2024-12-20 18:29:01', '', '75', '0', 'مروة عبد الرحيم', '2', '1', '3', '78', 'مروة عبد الرحيم', '3' ,'0','','','','','-1','0','0','0','0','0','455','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '455', userid = '75' WHERE clientid = '97';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('97','0.00','455','0','اضافة فاتورة مبيعات','150469', '455', '2024-12-20 18:29:01', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '455', '0', null, '0', null, null,'', '0','1','1','455','1','2024-12-20 18:27:56','0','0');
UPDATE client SET  inUse = 0 where clientid = 97;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','H1511', '150469', '14', '15975', '1', '430', '430', '0', '', '1', '2024-12-20 18:29:01', '15975', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','430','430','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 350, lastbuyprice_withDiscountAndTax = 350
                where sellbilldetailid = 549795;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15975, '2024-12-20', 430, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 430, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-20 18:29:01' WHERE storedetailid = '15974';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15975', '1', '1', '1', '150469', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-20 18:29:01','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150469', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 18:29:01', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150469', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-20 18:29:01', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','5','5','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 78 where clientid = 97;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 455, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+455, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (97, '2024-12-20', 455, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+455, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 455, 350, 350
                    , 350, 350, 350, 350, 350, 350)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+455, netSellCostBuyPrice = netSellCostBuyPrice+350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+350
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+350
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+350
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+350
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+350
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+350;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659b0c076b8 and sellbillId = 150469 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:59:02";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:29:02", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:29:02', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:59:07";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:29:07", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:29:07', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659660bf3dc
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:08:00', '067659660bf3dc', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2024-12-20 18:29:07', '', '9', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150470', '0', '2024-12-20 18:29:07', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 18:08:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33432;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('270','06617', '150470', '5', '15106', '1', '200', '200', '0', '', '1', '2024-12-20 18:29:07', '15106', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33432-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 270.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 270.00, meanbuyprice_withDiscount = 270.00
        
                where sellbilldetailid = 549798;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15106, '2024-12-20', 200, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '9', storedetaildate = '2024-12-20 18:29:07' WHERE storedetailid = '15105';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15106', '1', '1', '1', '150470', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '9', '2024-12-20 18:29:07','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '10680',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('10480','200', '0', '1', 'اضافة فاتورة مبيعات', '150470', '10680', '2024-12-20 18:29:07', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 3 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 200, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 200, 270, 270
                    , 270, 270, 270, 270, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+270
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+270
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+270
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+270
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+270
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+270
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659660bf3dc and sellbillId = 150470 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 14:59:08";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:29:08", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:29:08', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('A317','','6','295','360', '360','360', '2024-12-20', '0', '77', '1', '0A317', '0', '0', '0', '0', '0', '295','295','295','295','295','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','295','295','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16536, 1,'2024-12-20 18:29:54',77)
                ON DUPLICATE KEY UPDATE productid = 16536, edited = 1, sysdate = '2024-12-20 18:29:54', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16536', '1', '2024-12-20', '77', '0','1653601','360','360','360','295','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16536', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16536', '1', '0', '0', '16536', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('A316','','6','520','620', '620','620', '2024-12-20', '0', '77', '1', '0A316', '0', '0', '0', '0', '0', '520','520','520','520','520','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','520','520','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16537, 1,'2024-12-20 18:30:15',77)
                ON DUPLICATE KEY UPDATE productid = 16537, edited = 1, sysdate = '2024-12-20 18:30:15', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16537', '1', '2024-12-20', '77', '0','1653701','620','620','620','520','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16537', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16537', '1', '0', '0', '16537', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:00:27";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:30:27", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:30:27', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('A314','','6','260','320', '320','320', '2024-12-20', '0', '77', '1', '0A314', '0', '0', '0', '0', '0', '260','260','260','260','260','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','260','260','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16538, 1,'2024-12-20 18:30:34',77)
                ON DUPLICATE KEY UPDATE productid = 16538, edited = 1, sysdate = '2024-12-20 18:30:34', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16538', '1', '2024-12-20', '77', '0','1653801','320','320','320','260','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16538', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16538', '1', '0', '0', '16538', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7332','','5','280','350', '350','350', '2024-12-20', '0', '77', '1', '07332', '0', '0', '0', '0', '0', '280','280','280','280','280','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','280','280','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16539, 1,'2024-12-20 18:31:00',77)
                ON DUPLICATE KEY UPDATE productid = 16539, edited = 1, sysdate = '2024-12-20 18:31:00', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16539', '1', '2024-12-20', '77', '0','1653901','350','350','350','280','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16539', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16539', '1', '0', '0', '16539', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:01:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:31:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:31:00', '2', 'remove', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=remove&id=248060&action=122337');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController delete - with clientdebtchangeId =248060
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3108,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '3624', userid = '2' WHERE clientid = '3108';
UPDATE client SET  inUse = 0 where clientid = 3108;
UPDATE clientdebtchange SET del='1' WHERE clientdebtchangeid = '248060';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid, del,dailyentryid , num , billid ,paytype,seller,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments) VALUES ('3108','2205.00','1419.000','0','الغاء سداد ديون عميل','248060', '3624', '2024-12-20 18:31:00', '2', 'clientPayedDeptController.php', '', '1419', '0', null, '1', '122337', null, null,'','0','1','1','1419','1','','0','0');
UPDATE save SET  savecurrentvalue = '158564.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('159983.50','1419', '1', '2', 'الغاء سداد ديون عميل', '248064', '158564.5', '2024-12-20 18:31:01', '2',  'clientPayedDeptController.php','0','','0');
UPDATE dailyentry SET totalcreditor = '1419.00', totaldebtor = '1419.00', thedate = '2024-12-20', userid = '2', `condition` = '0', reverseofid = '-10', dDateTime = '2024-12-20 18:27:56', entryComment = 'اضافة ايصال سداد للعميل ام حمزة الاسماعلية Z19', fromFlag = '1',related='0',isopeningentry='0',operationId='248060',operationDetailLink='clientPayedDeptController.php?do=show&id=248060' WHERE id = '122337';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1419.00', '1419.00', '2024-12-20', '2', '0', '122337', '2024-12-20 18:31:01','تم عكس القيد رقم 122337 ','1','0','0','0','0','');
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122338', '-1', '1419.00', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1419', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122338', '-1', '1419.00', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1419', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController delete end - with clientdebtchangeId =248060
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:01:01";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:31:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:31:01', '2', 'sucess', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:01:03";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:31:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:31:03', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:01:11";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:31:11", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:31:11', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659094836b6
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9868,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 17:43:16', '067659094836b6', '9868', '0.00', '2909', '0', '1', '2909.00', '2909', '0', '2909', '1', '2024-12-20 18:31:11', '', '75', '0', 'منة الكردي', '2', '1', '3', '98', 'منة الكردي', '15' ,'0','','','','','-1','0','0','0','0','0','2909','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2909', userid = '75' WHERE clientid = '9868';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9868','0.00','2909','0','اضافة فاتورة مبيعات','150471', '2909', '2024-12-20 18:31:11', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2909', '0', null, '0', null, null,'', '0','1','1','2909','1','2024-12-20 17:43:16','0','0');
UPDATE client SET  inUse = 0 where clientid = 9868;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('440','05942', '150471', '5', '13255', '1', '280', '280', '0', '', '1', '2024-12-20 18:31:11', '13255', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','280','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 440.00 , meanbuyprice = 442.00, lastbuyprice_withDiscount = 440.00, meanbuyprice_withDiscount = 442.00
        
                where sellbilldetailid = 549799;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13255, '2024-12-20', 280, 440, 440
                    , 442, 440, 442, 442.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+442
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+442
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+442.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 280, 440, 440
                    , 442, 440, 442, 442.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+442
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+442
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+442.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 18:31:11' WHERE storedetailid = '13254';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13255', '1', '1', '1', '150471', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 18:31:11','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('390','0H949', '150471', '14', '9135', '1', '555', '555', '0', '', '1', '2024-12-20 18:31:11', '9135', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','555','555','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 390.00 , meanbuyprice = 650.00, lastbuyprice_withDiscount = 390.00, meanbuyprice_withDiscount = 650.00
        
                where sellbilldetailid = 549800;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9135, '2024-12-20', 555, 390, 390
                    , 650, 390, 650, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+555, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+390
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 555, 390, 390
                    , 650, 390, 650, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+555, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+390
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-20 18:31:11' WHERE storedetailid = '9134';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9135', '1', '1', '1', '150471', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-20 18:31:11','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('300','06182', '150471', '5', '14058', '1', '245', '245', '0', '', '1', '2024-12-20 18:31:11', '14058', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','245','245','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        
                where sellbilldetailid = 549801;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14058, '2024-12-20', 245, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+245, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 245, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+245, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-20 18:31:11' WHERE storedetailid = '14057';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14058', '1', '1', '1', '150471', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-20 18:31:11','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('495','05851', '150471', '5', '13037', '1', '360', '360', '0', '', '1', '2024-12-20 18:31:11', '13037', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 495.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 495.00
        
                where sellbilldetailid = 549802;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13037, '2024-12-20', 360, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 360, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '75', storedetaildate = '2024-12-20 18:31:11' WHERE storedetailid = '13036';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13037', '1', '1', '1', '150471', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '75', '2024-12-20 18:31:11','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('375','05936', '150471', '5', '13245', '1', '130', '130', '0', '', '1', '2024-12-20 18:31:11', '13245', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','130','130','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 375.00 , meanbuyprice = 375.00, lastbuyprice_withDiscount = 375.00, meanbuyprice_withDiscount = 375.00
        
                where sellbilldetailid = 549803;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13245, '2024-12-20', 130, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+375
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 130, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+375
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-20 18:31:11' WHERE storedetailid = '13244';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13245', '1', '1', '1', '150471', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-20 18:31:11','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('495','05605', '150471', '5', '12199', '1', '225', '225', '0', '', '1', '2024-12-20 18:31:11', '12199', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','225','225','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 490.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 490.00
        
                where sellbilldetailid = 549804;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12199, '2024-12-20', 225, 495, 495
                    , 490, 495, 490, 488.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+490
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+490
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+488.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 225, 495, 495
                    , 490, 495, 490, 488.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+490
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+490
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+488.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-20 18:31:11' WHERE storedetailid = '12198';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12199', '1', '1', '1', '150471', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-20 18:31:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33698;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('165','06640', '150471', '5', '15210', '1', '215', '215', '0', '', '1', '2024-12-20 18:31:12', '15210', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33698-1,','1','1','0','0','215','215','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 4785.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 4785.00
        
                where sellbilldetailid = 549805;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15210, '2024-12-20', 215, 165, 165
                    , 4785, 165, 4785, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+215, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4785
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4785
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 215, 165, 165
                    , 4785, 165, 4785, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+215, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4785
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4785
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-3', userid = '75', storedetaildate = '2024-12-20 18:31:12' WHERE storedetailid = '15209';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15210', '1', '1', '1', '150471', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-2', '-3', '75', '2024-12-20 18:31:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 30042;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('210','B1188', '150471', '2', '13463', '2', '145', '290', '0', '', '1', '2024-12-20 18:31:12', '13463', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30042-2,','1','1','0','0','145','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
        
                where sellbilldetailid = 549806;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13463, '2024-12-20', 290, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '75', storedetaildate = '2024-12-20 18:31:12' WHERE storedetailid = '13462';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13463', '1', '2', '1', '150471', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '14', '75', '2024-12-20 18:31:12','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','عرض 140', '150471', '18', '10348', '3', '145', '435', '0', '', '1', '2024-12-20 18:31:12', '10348', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','145','435','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        
                where sellbilldetailid = 549807;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10348, '2024-12-20', 435, 420, 420
                    , 420, 420, 420, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+435, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 435, 420, 420
                    , 420, 420, 420, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+435, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-15', userid = '75', storedetaildate = '2024-12-20 18:31:12' WHERE storedetailid = '10347';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10348', '1', '3', '1', '150471', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-12', '-15', '75', '2024-12-20 18:31:12','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('125','عرض 125', '150471', '18', '10350', '1', '125', '125', '0', '', '1', '2024-12-20 18:31:12', '10350', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','125','125','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 125.00 , meanbuyprice = 125.00, lastbuyprice_withDiscount = 125.00, meanbuyprice_withDiscount = 125.00
        
                where sellbilldetailid = 549808;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10350, '2024-12-20', 125, 125, 125
                    , 125, 125, 125, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 125, 125, 125
                    , 125, 125, 125, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-29', userid = '75', storedetaildate = '2024-12-20 18:31:12' WHERE storedetailid = '10349';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10350', '1', '1', '1', '150471', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-28', '-29', '75', '2024-12-20 18:31:12','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150471', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 18:31:12', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150471', '17', '10291', '1', '29', '29', '0', '', '1', '2024-12-20 18:31:12', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','29','29','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 98 where clientid = 9868;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2909, 3625, 3625
                    , 8502, 3625, 8502, 3075.83
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2909, sellCostBuyPrice =sellCostBuyPrice+3625
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3625, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8502
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3625, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8502
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3075.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9868, '2024-12-20', 2909, 3625, 3625
                    , 8502, 3625, 8502, 3075.83
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2909, sellCostBuyPrice =sellCostBuyPrice+3625
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3625, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8502
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3625, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8502
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3075.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2909, 3625, 3625
                    , 8502, 3625, 8502, 3075.83, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2909, netSellCostBuyPrice = netSellCostBuyPrice+3625
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3625
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+8502
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3625
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+8502
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+3075.83
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659094836b6 and sellbillId = 150471 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:01:12";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:31:12", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:31:12', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:01:14";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:31:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:31:14', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('A315','','6','400','520', '520','520', '2024-12-20', '0', '77', '1', '0A315', '0', '0', '0', '0', '0', '400','400','400','400','400','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','400','400','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16540, 1,'2024-12-20 18:31:25',77)
                ON DUPLICATE KEY UPDATE productid = 16540, edited = 1, sysdate = '2024-12-20 18:31:25', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16540', '1', '2024-12-20', '77', '0','1654001','520','520','520','400','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16540', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16540', '1', '0', '0', '16540', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:01:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:31:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:31:38', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248066
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10771,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 18:31:38', userid = '2' WHERE clientid = '10771';
UPDATE client SET  inUse = 0 where clientid = 10771;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10771','1419.00','1419','1','ايصال تحصيل (( قبض من عميل ))','248066', '0', '2024-12-20 18:31:14', '2', 'clientPayedDeptController.php', '   ', '1419', '0', null, '0', null, null,'', '-1','1','1','1419','1','','3671','0');
UPDATE save SET  savecurrentvalue = '159983.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('158564.50','1419', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248066', '159983.5', '2024-12-20 18:31:38', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1419', '1419', '2024-12-20', '2', '0', '0', '2024-12-20 18:31:38','اضافة ايصال سداد للعميل عروب الزقازيق 52','1','0','0','0','248066','clientPayedDeptController.php?do=show&id=248066');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122339', '-1', '1419', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1419', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122339', '12613', '1419', '','0');
UPDATE accountstree SET name = 'عروب الزقازيق 52', customName = 'عروب الزقازيق 52', customNameEn = 'عروب الزقازيق 52', nameEn = 'عروب الزقازيق 52', parent = '58', accountNature = '0', theValue = '-1419', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-20 15:58:00' WHERE id = '12613';
UPDATE clientdebtchange SET clientid = '10771', clientdebtchangebefore = '1419.000', clientdebtchangeamount = '1419.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248066', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 18:31:14', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1419.00',discount='', reciptid='0', dailyentryid = '122339',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1419',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248066';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248066 -clientdebtchangeId = 248066
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:01:39";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:31:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:31:39', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:01:55";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:31:55", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:31:55', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659b5478509
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:29:08', '067659b5478509', '1', '0.00', '0', '0', '1', '325.00', '325', '325', '0', '1', '2024-12-20 18:31:56', '', '9', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','325','0','','0','0','325','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150472', '0', '2024-12-20 18:31:56', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '325', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 18:29:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29838;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','05956', '150472', '5', '13289', '1', '325', '325', '0', '', '1', '2024-12-20 18:31:56', '13289', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29838-1,','1','1','0','0','325','325','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 744.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 744.00
        
                where sellbilldetailid = 549811;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13289, '2024-12-20', 325, 350, 350
                    , 744, 350, 744, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+744
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+744
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 325, 350, 350
                    , 744, 350, 744, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+744
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+744
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '31', userid = '9', storedetaildate = '2024-12-20 18:31:56' WHERE storedetailid = '13288';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13289', '1', '1', '1', '150472', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32', '31', '9', '2024-12-20 18:31:56','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '11005',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('10680','325', '0', '1', 'اضافة فاتورة مبيعات', '150472', '11005', '2024-12-20 18:31:56', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 325, 350, 350
                    , 744, 350, 744, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+744
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+744
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 325, 350, 350
                    , 744, 350, 744, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+744
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+744
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 325, 350, 350
                    , 744, 350, 744, 350, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+325, netSellCostBuyPrice = netSellCostBuyPrice+350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+744
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+350
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+744
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+350
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659b5478509 and sellbillId = 150472 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:01:56";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:31:56", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:31:56', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:01:57";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:31:57", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:31:57', '77', '', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:02:04";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:32:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:32:04', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248067
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3108,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 18:32:04', userid = '2' WHERE clientid = '3108';
UPDATE client SET  inUse = 0 where clientid = 3108;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3108','3624.00','3624','1','ايصال تحصيل (( قبض من عميل ))','248067', '0', '2024-12-20 18:31:39', '2', 'clientPayedDeptController.php', '   ', '3624', '0', null, '0', null, null,'', '-1','1','1','3624','1','','3672','0');
UPDATE save SET  savecurrentvalue = '163607.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('159983.50','3624', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248068', '163607.5', '2024-12-20 18:32:04', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '3624', '3624', '2024-12-20', '2', '0', '0', '2024-12-20 18:32:04','اضافة ايصال سداد للعميل ام حمزة الاسماعلية Z19','1','0','0','0','248068','clientPayedDeptController.php?do=show&id=248068');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122340', '-1', '3624', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '3624', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122340', '-1', '3624', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-3624', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '3108', clientdebtchangebefore = '3624.000', clientdebtchangeamount = '3624.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248067', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 18:31:39', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '3624.00',discount='', reciptid='0', dailyentryid = '122340',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='3624',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248068';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248067 -clientdebtchangeId = 248068
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:02:05";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:32:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:32:05', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:02:17";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:32:17", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:32:17', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:02:21";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:32:21", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:32:21', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659b4e95c1b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5383,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:29:02', '067659b4e95c1b', '5383', '0.00', '899', '0', '1', '899.00', '899', '0', '899', '1', '2024-12-20 18:32:21', '', '75', '0', 'خالد محي الدين 56', '2', '1', '3', '78', 'خالد محي الدين 56', '3' ,'0','','','','','-1','0','0','0','0','0','899','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '899', userid = '75' WHERE clientid = '5383';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5383','0.00','899','0','اضافة فاتورة مبيعات','150473', '899', '2024-12-20 18:32:21', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '899', '0', null, '0', null, null,'', '0','1','1','899','1','2024-12-20 18:29:02','0','0');
UPDATE client SET  inUse = 0 where clientid = 5383;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('870','H1545', '150473', '14', '16102', '1', '870', '870', '0', '', '1', '2024-12-20 18:32:21', '16102', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','870','870','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 870.00 , meanbuyprice = 870.00, lastbuyprice_withDiscount = 870.00, meanbuyprice_withDiscount = 870.00
        , lastbuyprice_withTax = 870, meanbuyprice_withTax = 870, lastbuyprice_withDiscountAndTax = 870
                where sellbilldetailid = 549812;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16102, '2024-12-20', 870, 870, 870
                    , 870, 870, 870, 870
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 870, 870, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+870, sellCostBuyPrice =sellCostBuyPrice+870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+870, sellCostMeanBuyPrice = sellCostMeanBuyPrice+870
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+870
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+870
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+870
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 870, 870, 870
                    , 870, 870, 870, 870
                    , 0, 0, 0, 0
                    , 0, 0, 0, 870, 870, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+870, sellCostBuyPrice =sellCostBuyPrice+870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+870, sellCostMeanBuyPrice = sellCostMeanBuyPrice+870
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+870
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+870
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+870
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-9', userid = '75', storedetaildate = '2024-12-20 18:32:21' WHERE storedetailid = '16101';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16102', '1', '1', '1', '150473', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-8', '-9', '75', '2024-12-20 18:32:21','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150473', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 18:32:22', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150473', '17', '10291', '1', '9', '9', '0', '', '1', '2024-12-20 18:32:22', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','9','9','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 78 where clientid = 5383;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 899, 870, 870
                    , 870, 870, 870, 870
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,870, 870, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+899, sellCostBuyPrice =sellCostBuyPrice+870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+870, sellCostMeanBuyPrice = sellCostMeanBuyPrice+870
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+870
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+870
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+870
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (5383, '2024-12-20', 899, 870, 870
                    , 870, 870, 870, 870
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,870, 870, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+899, sellCostBuyPrice =sellCostBuyPrice+870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+870, sellCostMeanBuyPrice = sellCostMeanBuyPrice+870
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+870
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+870
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+870
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 899, 870, 870
                    , 870, 870, 870, 870, 870, 870)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+899, netSellCostBuyPrice = netSellCostBuyPrice+870
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+870
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+870
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+870
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+870
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+870
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+870
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+870;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659b4e95c1b and sellbillId = 150473 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:02:22";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:32:22", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:32:22', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:02:25";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:32:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:32:25', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248069
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3998,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 18:32:25', userid = '2' WHERE clientid = '3998';
UPDATE client SET  inUse = 0 where clientid = 3998;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3998','303.00','303','1','ايصال تحصيل (( قبض من عميل ))','248069', '0', '2024-12-20 18:32:05', '2', 'clientPayedDeptController.php', '   ', '303', '0', null, '0', null, null,'', '-1','1','1','303','1','','3673','0');
UPDATE save SET  savecurrentvalue = '163910.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('163607.50','303', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248070', '163910.5', '2024-12-20 18:32:25', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '303', '303', '2024-12-20', '2', '0', '0', '2024-12-20 18:32:25','اضافة ايصال سداد للعميل ام جون 41','1','0','0','0','248070','clientPayedDeptController.php?do=show&id=248070');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122341', '-1', '303', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '303', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122341', '-1', '303', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-303', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '3998', clientdebtchangebefore = '303.000', clientdebtchangeamount = '303.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248069', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 18:32:05', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '303.00',discount='', reciptid='0', dailyentryid = '122341',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='303',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248070';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248069 -clientdebtchangeId = 248070
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:02:26";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:32:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:32:26', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:02:44";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:32:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:32:44', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248071
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3337,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '924' , clientdate = '2024-12-20 18:32:44', userid = '2' WHERE clientid = '3337';
UPDATE client SET  inUse = 0 where clientid = 3337;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3337','1714.00','790','1','ايصال تحصيل (( قبض من عميل ))','248071', '924', '2024-12-20 18:32:26', '2', 'clientPayedDeptController.php', '   ', '790', '0', null, '0', null, null,'', '-1','1','1','790','1','','3674','0');
UPDATE save SET  savecurrentvalue = '164700.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('163910.50','790', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248071', '164700.5', '2024-12-20 18:32:44', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '790', '790', '2024-12-20', '2', '0', '0', '2024-12-20 18:32:44','اضافة ايصال سداد للعميل هاجر السبيلي f48','1','0','0','0','248071','clientPayedDeptController.php?do=show&id=248071');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122342', '-1', '790', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '790', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122342', '-1', '790', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-790', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '3337', clientdebtchangebefore = '1714.000', clientdebtchangeamount = '790.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248071', clientdebtchangeafter = '924.000', clientdebtchangedate = '2024-12-20 18:32:26', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '790.00',discount='', reciptid='0', dailyentryid = '122342',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='790',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248071';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248071 -clientdebtchangeId = 248071
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:02:45";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:32:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:32:45', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:04:25";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:34:25", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:34:25', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659c16b8df1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10577,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:32:22', '067659c16b8df1', '10577', '0.00', '1025', '0', '1', '1025.00', '1025', '0', '1025', '1', '2024-12-20 18:34:25', '', '75', '0', 'اسراء شبراوي 52', '2', '1', '3', '98', 'اسراء شبراوي 52', '5' ,'0','','','','','-1','0','0','0','0','0','1025','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1025', userid = '75' WHERE clientid = '10577';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10577','0.00','1025','0','اضافة فاتورة مبيعات','150474', '1025', '2024-12-20 18:34:25', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1025', '0', null, '0', null, null,'', '0','1','1','1025','1','2024-12-20 18:32:22','0','0');
UPDATE client SET  inUse = 0 where clientid = 10577;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35929;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','07200', '150474', '5', '16305', '1', '300', '300', '0', '', '1', '2024-12-20 18:34:25', '16305', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35929-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 549815;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16305, '2024-12-20', 300, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '75', storedetaildate = '2024-12-20 18:34:25' WHERE storedetailid = '16304';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16305', '1', '1', '1', '150474', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-20 18:34:25','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29514;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('445','05904', '150474', '5', '13171', '1', '320', '320', '0', '', '1', '2024-12-20 18:34:25', '13171', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29514-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 445.00 , meanbuyprice = 445.00, lastbuyprice_withDiscount = 445.00, meanbuyprice_withDiscount = 445.00
        
                where sellbilldetailid = 549816;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13171, '2024-12-20', 320, 445, 445
                    , 445, 445, 445, 445
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+445
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+445, sellCostMeanBuyPrice = sellCostMeanBuyPrice+445
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+445, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+445
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+445
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 320, 445, 445
                    , 445, 445, 445, 445
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+445
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+445, sellCostMeanBuyPrice = sellCostMeanBuyPrice+445
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+445, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+445
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+445
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '75', storedetaildate = '2024-12-20 18:34:25' WHERE storedetailid = '13170';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13171', '1', '1', '1', '150474', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '75', '2024-12-20 18:34:25','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','06188', '150474', '5', '14075', '1', '375', '375', '0', '', '1', '2024-12-20 18:34:25', '14075', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','375','375','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        
                where sellbilldetailid = 549817;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14075, '2024-12-20', 375, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+375, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 375, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+375, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '75', storedetaildate = '2024-12-20 18:34:25' WHERE storedetailid = '14074';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14075', '1', '1', '1', '150474', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '75', '2024-12-20 18:34:25','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150474', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 18:34:25', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150474', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-20 18:34:25', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','10','10','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 98 where clientid = 10577;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1025, 1045, 1045
                    , 1045, 1045, 1045, 1045
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1025, sellCostBuyPrice =sellCostBuyPrice+1045
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1045, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1045
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1045, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1045
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1045
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10577, '2024-12-20', 1025, 1045, 1045
                    , 1045, 1045, 1045, 1045
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1025, sellCostBuyPrice =sellCostBuyPrice+1045
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1045, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1045
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1045, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1045
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1045
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1025, 1045, 1045
                    , 1045, 1045, 1045, 1045, 250, 250)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1025, netSellCostBuyPrice = netSellCostBuyPrice+1045
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1045
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1045
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1045
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1045
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1045
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+250
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+250;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659c16b8df1 and sellbillId = 150474 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:04:26";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:34:26", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:34:26', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:05:12";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 18:35:12", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:35:12', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659b1faafc5
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4241,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:28:15', '067659b1faafc5', '4241', '-2645.00', '1072', '0', '1', '3717.00', '3717', '0', '3717', '1', '2024-12-20 18:35:13', '', '101', '0', 'بسنت عادل 25', '2', '1', '3', '88', 'بسنت عادل 25', '12' ,'0','','','','','-1','0','0','0','0','0','3717','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1072', userid = '101' WHERE clientid = '4241';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4241','-2645.00','3717','0','اضافة فاتورة مبيعات','150475', '1072', '2024-12-20 18:35:13', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3717', '0', null, '0', null, null,'', '0','1','1','3717','1','2024-12-20 18:28:15','0','0');
UPDATE client SET  inUse = 0 where clientid = 4241;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('280','R2941', '150475', '1', '15283', '1', '325', '325', '0', '', '1', '2024-12-20 18:35:13', '15283', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','325','325','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        
                where sellbilldetailid = 549820;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15283, '2024-12-20', 325, 280, 280
                    , 280, 280, 280, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 325, 280, 280
                    , 280, 280, 280, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-6', userid = '101', storedetaildate = '2024-12-20 18:35:13' WHERE storedetailid = '15282';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15283', '1', '1', '1', '150475', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-5', '-6', '101', '2024-12-20 18:35:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29854;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('260','05891', '150475', '5', '13153', '1', '310', '310', '0', '', '1', '2024-12-20 18:35:13', '13153', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29854-1,','1','1','0','0','310','310','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 565.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 565.00
        
                where sellbilldetailid = 549821;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13153, '2024-12-20', 310, 260, 260
                    , 565, 260, 565, 259.47
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+565
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+565
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.47
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 310, 260, 260
                    , 565, 260, 565, 259.47
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+565
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+565
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.47
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '36', userid = '101', storedetaildate = '2024-12-20 18:35:13' WHERE storedetailid = '13152';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13153', '1', '1', '1', '150475', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37', '36', '101', '2024-12-20 18:35:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36346;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('400','R3319', '150475', '1', '16223', '1', '470', '470', '0', '', '1', '2024-12-20 18:35:13', '16223', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36346-1,','1','1','0','0','470','470','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549822;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16223, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '101', storedetaildate = '2024-12-20 18:35:13' WHERE storedetailid = '16222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16223', '1', '1', '1', '150475', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '101', '2024-12-20 18:35:13','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('495','06307', '150475', '5', '14340', '1', '420', '420', '0', '', '1', '2024-12-20 18:35:13', '14340', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 495.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 495.00
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 71, lastbuyprice_withDiscountAndTax = 495
                where sellbilldetailid = 549823;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14340, '2024-12-20', 420, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 495, 71, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+71
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 71, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+71
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-14', userid = '101', storedetaildate = '2024-12-20 18:35:13' WHERE storedetailid = '14339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14340', '1', '1', '1', '150475', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-13', '-14', '101', '2024-12-20 18:35:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29022;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','R2642', '150475', '1', '12941', '1', '250', '250', '0', '', '1', '2024-12-20 18:35:13', '12941', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29022-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 1560.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 1560.00
        
                where sellbilldetailid = 549824;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12941, '2024-12-20', 250, 240, 240
                    , 1560, 240, 1560, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1560
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1560
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 250, 240, 240
                    , 1560, 240, 1560, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1560
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1560
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-6', userid = '101', storedetaildate = '2024-12-20 18:35:13' WHERE storedetailid = '12940';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12941', '1', '1', '1', '150475', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-5', '-6', '101', '2024-12-20 18:35:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35973;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('500','H1571', '150475', '14', '16204', '1', '610', '610', '0', '', '1', '2024-12-20 18:35:13', '16204', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35973-1,','1','1','0','0','610','610','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 1105.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 1105.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 1710, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 549825;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16204, '2024-12-20', 610, 500, 500
                    , 1105, 500, 1105, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 1710, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1105
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1105
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1710
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 500, 500
                    , 1105, 500, 1105, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 1710, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1105
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1105
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1710
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-2', userid = '101', storedetaildate = '2024-12-20 18:35:13' WHERE storedetailid = '16203';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16204', '1', '1', '1', '150475', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-1', '-2', '101', '2024-12-20 18:35:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34770;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('190','0K791', '150475', '7', '15784', '1', '240', '240', '0', '', '1', '2024-12-20 18:35:13', '15784', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34770-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 190, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 549826;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15784, '2024-12-20', 240, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+190
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 240, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+190
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 18:35:13' WHERE storedetailid = '15783';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15784', '1', '1', '1', '150475', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '101', '2024-12-20 18:35:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 22469;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('220','0K479', '150475', '7', '10242', '1', '155', '155', '0', '', '1', '2024-12-20 18:35:13', '10242', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','22469-1,','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
        
                where sellbilldetailid = 549827;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10242, '2024-12-20', 155, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '101', storedetaildate = '2024-12-20 18:35:13' WHERE storedetailid = '10241';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10242', '1', '1', '1', '150475', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '101', '2024-12-20 18:35:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36103;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','07260', '150475', '5', '16374', '1', '300', '300', '0', '', '1', '2024-12-20 18:35:13', '16374', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36103-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 231.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 231.00
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 238, lastbuyprice_withDiscountAndTax = 225
                where sellbilldetailid = 549828;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16374, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+231
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+231
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+225
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+238
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '101', storedetaildate = '2024-12-20 18:35:13' WHERE storedetailid = '16373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16374', '1', '1', '1', '150475', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '101', '2024-12-20 18:35:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35977;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('510','07197', '150475', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-20 18:35:13', '16297', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35977-1,','1','1','0','0','580','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 503.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 503.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 507, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 549829;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16297, '2024-12-20', 580, 500, 500
                    , 503, 500, 503, 507.69
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 507, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+507.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+507
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 580, 500, 500
                    , 503, 500, 503, 507.69
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 507, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+507.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+507
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '132', userid = '101', storedetaildate = '2024-12-20 18:35:13' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '150475', 'اضافة فاتورة مبيعات', 'sellbillController.php', '133', '132', '101', '2024-12-20 18:35:13','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150475', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 18:35:13', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150475', '17', '10291', '1', '37', '37', '0', '', '1', '2024-12-20 18:35:13', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','37','37','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 88 where clientid = 4241;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 3717, 3310, 3310
                    , 5549, 3310, 5549, 3049.66
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2310, 3116, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3717, sellCostBuyPrice =sellCostBuyPrice+3310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+5549
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+5549
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3049.66
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3116
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4241, '2024-12-20', 3717, 3310, 3310
                    , 5549, 3310, 5549, 3049.66
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2310, 3116, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3717, sellCostBuyPrice =sellCostBuyPrice+3310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+5549
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+5549
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3049.66
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3116
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3717, 3310, 3310
                    , 5549, 3310, 5549, 3049.66, 2310, 3116)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3717, netSellCostBuyPrice = netSellCostBuyPrice+3310
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3310
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+5549
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3310
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+5549
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+3049.66
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2310
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+3116;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659b1faafc5 and sellbillId = 150475 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:05:14";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-20 18:35:14", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:35:14', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:05:39";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:35:39", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:35:39', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659bfcd338b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:31:56', '067659bfcd338b', '1', '0.00', '0', '0', '1', '1060.00', '1060', '1060', '0', '1', '2024-12-20 18:35:40', '', '9', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','1060','0','','0','0','1060','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150476', '0', '2024-12-20 18:35:40', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1060', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 18:31:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36186;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('455','07276', '150476', '5', '16391', '1', '510', '510', '0', '', '1', '2024-12-20 18:35:40', '16391', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36186-1,','1','1','0','0','510','510','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 455.00 , meanbuyprice = 455.00, lastbuyprice_withDiscount = 455.00, meanbuyprice_withDiscount = 455.00
        , lastbuyprice_withTax = 455, meanbuyprice_withTax = 455, lastbuyprice_withDiscountAndTax = 455
                where sellbilldetailid = 549832;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16391, '2024-12-20', 510, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+455
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+455, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+455, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+455
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+455
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+455
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 510, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+455
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+455, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+455, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+455
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+455
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+455
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '9', storedetaildate = '2024-12-20 18:35:40' WHERE storedetailid = '16390';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16391', '1', '1', '1', '150476', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '9', '2024-12-20 18:35:40','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('480','07193', '150476', '5', '16309', '1', '550', '550', '0', '', '1', '2024-12-20 18:35:40', '16309', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','550','550','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 480.00 , meanbuyprice = 480.00, lastbuyprice_withDiscount = 480.00, meanbuyprice_withDiscount = 480.00
        , lastbuyprice_withTax = 480, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 480
                where sellbilldetailid = 549833;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16309, '2024-12-20', 550, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 550, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-10', userid = '9', storedetaildate = '2024-12-20 18:35:40' WHERE storedetailid = '16308';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16309', '1', '1', '1', '150476', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-9', '-10', '9', '2024-12-20 18:35:40','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '12065',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('11005','1060', '0', '1', 'اضافة فاتورة مبيعات', '150476', '12065', '2024-12-20 18:35:40', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 3 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1060, 935, 935
                    , 935, 935, 935, 935
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,935, 935, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1060, sellCostBuyPrice =sellCostBuyPrice+935
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+935, sellCostMeanBuyPrice = sellCostMeanBuyPrice+935
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+935, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+935
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+935
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+935
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+935
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1060, 935, 935
                    , 935, 935, 935, 935
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,935, 935, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1060, sellCostBuyPrice =sellCostBuyPrice+935
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+935, sellCostMeanBuyPrice = sellCostMeanBuyPrice+935
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+935, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+935
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+935
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+935
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+935
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1060, 935, 935
                    , 935, 935, 935, 935, 935, 935)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1060, netSellCostBuyPrice = netSellCostBuyPrice+935
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+935
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+935
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+935
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+935
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+935
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+935
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+935;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659bfcd338b and sellbillId = 150476 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:05:40";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:35:40", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:35:40', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:06:12";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 18:36:12", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 18:36:12', '101', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:06:13";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:06:16";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 18:36:16", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:36:16', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:06:22";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 18:36:22", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:36:22', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:06:37";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 18:36:37", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:36:37', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150475');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:07:05";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 18:37:05", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:37:05', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:07:29";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 18:37:29", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:37:29', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150468');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('فاطمه يوسف' , '', '', '', '0', '', '0', '2024-12-20 18:39:19', '9', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-20','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10779', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10779','0','0','0','إضافة عميل جديد','10779', '0', '2024-12-20 18:39:19', '9', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('فاطمه يوسف', 'فاطمه يوسف', 'فاطمه يوسف', 'فاطمه يوسف', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '9', '0', '2024-12-20 18:39:19');
UPDATE client SET clientname = 'فاطمه يوسف', clientaddress = '', clientphone = '', clientmobile = '', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-20', userid = '9'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12625',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10779';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:09:53";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:39:53", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:39:53', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659bd10c9ee
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(484,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:31:13', '067659bd10c9ee', '484', '-2.00', '1261', '0', '1', '1263.00', '1263', '0', '1263', '1', '2024-12-20 18:39:53', '', '75', '0', 'هند شكر الله', '2', '1', '3', '89', 'هند شكر الله', '8' ,'0','','','','','-1','0','0','0','0','0','1263','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1261', userid = '75' WHERE clientid = '484';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('484','-2.00','1263','0','اضافة فاتورة مبيعات','150477', '1261', '2024-12-20 18:39:53', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1263', '0', null, '0', null, null,'', '0','1','1','1263','1','2024-12-20 18:31:13','0','0');
UPDATE client SET  inUse = 0 where clientid = 484;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 22300;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','0K393', '150477', '7', '9386', '2', '210', '420', '0', '', '1', '2024-12-20 18:39:53', '9386', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','22300-2,','1','1','0','0','210','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 272.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 272.00
        
                where sellbilldetailid = 549834;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9386, '2024-12-20', 420, 500, 500
                    , 544, 500, 544, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+544
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+544
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 500, 500
                    , 544, 500, 544, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+544
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+544
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-13', userid = '75', storedetaildate = '2024-12-20 18:39:53' WHERE storedetailid = '9385';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9386', '1', '2', '1', '150477', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-11', '-13', '75', '2024-12-20 18:39:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36142;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07226', '150477', '5', '16294', '1', '210', '210', '0', '', '1', '2024-12-20 18:39:53', '16294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36142-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 151.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 151.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 153, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549835;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16294, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+151
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+151
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+153.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '68', userid = '75', storedetaildate = '2024-12-20 18:39:53' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '1', '150477', 'اضافة فاتورة مبيعات', 'sellbillController.php', '69', '68', '75', '2024-12-20 18:39:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19902;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('310','0K388', '150477', '7', '9163', '1', '200', '200', '0', '', '1', '2024-12-20 18:39:53', '9163', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','19902-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 310.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 310.00
        
                where sellbilldetailid = 549836;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9163, '2024-12-20', 200, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '75', storedetaildate = '2024-12-20 18:39:53' WHERE storedetailid = '9162';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9163', '1', '1', '1', '150477', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-20 18:39:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('200','عرض 200', '150477', '18', '10353', '2', '200', '400', '0', '', '1', '2024-12-20 18:39:53', '10353', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        
                where sellbilldetailid = 549837;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10353, '2024-12-20', 400, 400, 400
                    , 400, 400, 400, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 400, 400
                    , 400, 400, 400, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-31', userid = '75', storedetaildate = '2024-12-20 18:39:53' WHERE storedetailid = '10352';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10353', '1', '2', '1', '150477', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-29', '-31', '75', '2024-12-20 18:39:53','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150477', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 18:39:53', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150477', '17', '10291', '1', '13', '13', '0', '', '1', '2024-12-20 18:39:53', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','13','13','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 89 where clientid = 484;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1263, 1365, 1365
                    , 1405, 1365, 1405, 963.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1263, sellCostBuyPrice =sellCostBuyPrice+1365
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1365, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1405
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1365, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1405
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+963.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (484, '2024-12-20', 1263, 1365, 1365
                    , 1405, 1365, 1405, 963.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1263, sellCostBuyPrice =sellCostBuyPrice+1365
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1365, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1405
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1365, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1405
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+963.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+153
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1263, 1365, 1365
                    , 1405, 1365, 1405, 963.12, 155, 153)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1263, netSellCostBuyPrice = netSellCostBuyPrice+1365
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1365
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1405
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1365
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1405
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+963.12
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+155
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+153;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659bd10c9ee and sellbillId = 150477 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:09:53";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 18:39:53", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:39:53', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:10:14";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:40:14", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:40:14', '77', '', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:10:34";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:40:34", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:40:34', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:10:40";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:40:40", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:40:40', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659cdcd85a9
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10779,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:35:40', '067659cdcd85a9', '10779', '0.00', '1630', '0', '1', '1630.00', '1630', '0', '1630', '1', '2024-12-20 18:40:41', '', '9', '0', 'فاطمه يوسف', '1', '1', '3', '6', 'فاطمه يوسف', '3' ,'0','','','','','-1','0','0','0','0','0','1630','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1630', userid = '9' WHERE clientid = '10779';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10779','0.00','1630','0','اضافة فاتورة مبيعات','150478', '1630', '2024-12-20 18:40:41', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1630', '0', null, '0', null, null,'', '0','1','1','1630','1','2024-12-20 18:35:40','0','0');
UPDATE client SET  inUse = 0 where clientid = 10779;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36399;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('745','07305', '150478', '5', '16454', '1', '810', '810', '0', '', '1', '2024-12-20 18:40:41', '16454', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36399-1,','1','1','0','0','810','810','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 745.00 , meanbuyprice = 743.00, lastbuyprice_withDiscount = 745.00, meanbuyprice_withDiscount = 743.00
        , lastbuyprice_withTax = 745, meanbuyprice_withTax = 741, lastbuyprice_withDiscountAndTax = 745
                where sellbilldetailid = 549840;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16454, '2024-12-20', 810, 745, 745
                    , 743, 745, 743, 741.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 745, 741, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+743
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+743
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+741.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+741
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 810, 745, 745
                    , 743, 745, 743, 741.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 745, 741, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+743
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+743
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+741.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+741
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '36', userid = '9', storedetaildate = '2024-12-20 18:40:41' WHERE storedetailid = '16453';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16454', '1', '1', '1', '150478', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37', '36', '9', '2024-12-20 18:40:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36094;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('730','07143', '150478', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-20 18:40:41', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36094-1,','1','1','0','0','810','810','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 730.00 , meanbuyprice = 730.00, lastbuyprice_withDiscount = 730.00, meanbuyprice_withDiscount = 730.00
        , lastbuyprice_withTax = 730, meanbuyprice_withTax = 730, lastbuyprice_withDiscountAndTax = 730
                where sellbilldetailid = 549841;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16205, '2024-12-20', 810, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+730
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+730, sellCostMeanBuyPrice = sellCostMeanBuyPrice+730
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+730, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+730
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+730
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+730
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+730
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 810, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0, 730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+730
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+730, sellCostMeanBuyPrice = sellCostMeanBuyPrice+730
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+730, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+730
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+730
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+730
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+730
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '56', userid = '9', storedetaildate = '2024-12-20 18:40:41' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '150478', 'اضافة فاتورة مبيعات', 'sellbillController.php', '57', '56', '9', '2024-12-20 18:40:41','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150478', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-20 18:40:41', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','10','10','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 6 where clientid = 10779;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1630, 1475, 1475
                    , 1473, 1475, 1473, 1471.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1475, 1471, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1630, sellCostBuyPrice =sellCostBuyPrice+1475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1473
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1473
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1471.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1475
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1471
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10779, '2024-12-20', 1630, 1475, 1475
                    , 1473, 1475, 1473, 1471.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1475, 1471, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1630, sellCostBuyPrice =sellCostBuyPrice+1475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1473
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1473
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1471.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1475
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1471
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1630, 1475, 1475
                    , 1473, 1475, 1473, 1471.67, 1475, 1471)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1630, netSellCostBuyPrice = netSellCostBuyPrice+1475
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1475
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1473
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1475
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1473
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1471.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1475
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1471;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659cdcd85a9 and sellbillId = 150478 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:10:41";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:40:41", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:40:41', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('A313','','6','400','520', '520','520', '2024-12-20', '0', '77', '1', '0A313', '0', '0', '0', '0', '0', '400','400','400','400','400','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','400','400','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16541, 1,'2024-12-20 18:42:24',77)
                ON DUPLICATE KEY UPDATE productid = 16541, edited = 1, sysdate = '2024-12-20 18:42:24', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16541', '1', '2024-12-20', '77', '0','1654101','520','520','520','400','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16541', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16541', '1', '0', '0', '16541', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('A318','','6','310','410', '410','410', '2024-12-20', '0', '77', '1', '0A318', '0', '0', '0', '0', '0', '310','310','310','310','310','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','310','310','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16542, 1,'2024-12-20 18:42:46',77)
                ON DUPLICATE KEY UPDATE productid = 16542, edited = 1, sysdate = '2024-12-20 18:42:46', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16542', '1', '2024-12-20', '77', '0','1654201','410','410','410','310','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16542', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16542', '1', '0', '0', '16542', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:12:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:42:46", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:42:46', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659e09e5786
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:40:41', '067659e09e5786', '1', '0.00', '0', '0', '1', '730.00', '730', '730', '0', '1', '2024-12-20 18:42:46', '', '9', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','730','0','','0','0','730','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150479', '0', '2024-12-20 18:42:46', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '730', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 18:40:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35893;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('270','R3325', '150479', '1', '16290', '1', '350', '350', '0', '', '1', '2024-12-20 18:42:46', '16290', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35893-1,','1','1','0','0','350','350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 252.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 252.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 254, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 549843;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16290, '2024-12-20', 350, 250, 250
                    , 252, 250, 252, 256.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 254, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+252
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+252
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+256.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+254
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 350, 250, 250
                    , 252, 250, 252, 256.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 254, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+252
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+252
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+256.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+254
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '34', userid = '9', storedetaildate = '2024-12-20 18:42:46' WHERE storedetailid = '16289';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16290', '1', '1', '1', '150479', 'اضافة فاتورة مبيعات', 'sellbillController.php', '35', '34', '9', '2024-12-20 18:42:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36389;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('310','07301', '150479', '5', '16451', '1', '380', '380', '0', '', '1', '2024-12-20 18:42:47', '16451', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36389-1,','1','1','0','0','380','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 310.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 310.00
        , lastbuyprice_withTax = 310, meanbuyprice_withTax = 310, lastbuyprice_withDiscountAndTax = 310
                where sellbilldetailid = 549844;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16451, '2024-12-20', 380, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 380, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '22', userid = '9', storedetaildate = '2024-12-20 18:42:47' WHERE storedetailid = '16450';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16451', '1', '1', '1', '150479', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '9', '2024-12-20 18:42:47','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '12795',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('12065','730', '0', '1', 'اضافة فاتورة مبيعات', '150479', '12795', '2024-12-20 18:42:47', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 3 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 730, 560, 560
                    , 562, 560, 562, 566.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,560, 564, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+730, sellCostBuyPrice =sellCostBuyPrice+560
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+560, sellCostMeanBuyPrice = sellCostMeanBuyPrice+562
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+560, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+562
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+566.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+560
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+564
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 730, 560, 560
                    , 562, 560, 562, 566.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,560, 564, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+730, sellCostBuyPrice =sellCostBuyPrice+560
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+560, sellCostMeanBuyPrice = sellCostMeanBuyPrice+562
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+560, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+562
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+566.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+560
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+564
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 730, 560, 560
                    , 562, 560, 562, 566.67, 560, 564)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+730, netSellCostBuyPrice = netSellCostBuyPrice+560
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+560
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+562
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+560
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+562
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+566.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+560
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+564;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659e09e5786 and sellbillId = 150479 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:12:47";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:42:47", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:42:47', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:13:03";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:43:03", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:43:03', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('067659b34ab84d', '2024-12-20 18:28:36', '175', '311295.00', '348270', '0', '0', '36975',  '36975', '0', '36975', '1', '2024-12-20 18:43:03', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('0A317', '14179', '6', '16536', '15', '295', '4425', '0', '', '2024-12-20 18:43:03', '16536','','','0','0','0','0','0',null,'295','4425','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 18:28:36', 1, 16536, 0, 0
                    , 295, 15, 0, 0, 77, '2024-12-20 18:43:03')
                ON DUPLICATE KEY UPDATE buyprice = 295,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 18:43:03' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16536', '295', '15', '0', 'buyBillController.php', '32814', '', '0', '0');
UPDATE product SET  productBuyPrice = "295" WHERE productId = 16536 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32814 ;
UPDATE product SET productName = 'A317', productDescription = '', productCatId = '6', productBuyPrice = '295.00', productSellAllPrice = '360.00', productSellUnitPrice = '360.00', productSellHalfPrice = '360.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '0A317',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '295',lastbuyprice_withDiscount = '295',meanbuyprice = '295',meanbuyprice_withDiscount = '295' , productbuypricereal = '295.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='295',meanbuyprice_withTax='295',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='295'  WHERE productId = '16536';
UPDATE buybilldetail SET  lastbuyprice = 295 , meanbuyprice = 295, lastbuyprice_withDiscount = 295, meanbuyprice_withDiscount = 295
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295, lastbuyprice_withDiscountAndTax = 295
                where buybilldetailid = 32814;
UPDATE productunit SET proUnitBuyPrice  = 295 * productnumber WHERE productid = 16536;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16535';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16536', '1', '15', '0', '14179', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 18:28:36','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('0A316', '14179', '6', '16537', '15', '520', '7800', '0', '', '2024-12-20 18:43:03', '16537','','','0','0','0','0','0',null,'520','7800','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 18:28:36', 1, 16537, 0, 0
                    , 520, 15, 0, 0, 77, '2024-12-20 18:43:03')
                ON DUPLICATE KEY UPDATE buyprice = 520,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 18:43:03' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16537', '520', '15', '0', 'buyBillController.php', '32815', '', '0', '0');
UPDATE product SET  productBuyPrice = "520" WHERE productId = 16537 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32815 ;
UPDATE product SET productName = 'A316', productDescription = '', productCatId = '6', productBuyPrice = '520.00', productSellAllPrice = '620.00', productSellUnitPrice = '620.00', productSellHalfPrice = '620.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '0A316',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '520',lastbuyprice_withDiscount = '520',meanbuyprice = '520',meanbuyprice_withDiscount = '520' , productbuypricereal = '520.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='520',meanbuyprice_withTax='520',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='520'  WHERE productId = '16537';
UPDATE buybilldetail SET  lastbuyprice = 520 , meanbuyprice = 520, lastbuyprice_withDiscount = 520, meanbuyprice_withDiscount = 520
        , lastbuyprice_withTax = 520, meanbuyprice_withTax = 520, lastbuyprice_withDiscountAndTax = 520
                where buybilldetailid = 32815;
UPDATE productunit SET proUnitBuyPrice  = 520 * productnumber WHERE productid = 16537;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16536';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16537', '1', '15', '0', '14179', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 18:28:36','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('0A314', '14179', '6', '16538', '15', '260', '3900', '0', '', '2024-12-20 18:43:03', '16538','','','0','0','0','0','0',null,'260','3900','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 18:28:36', 1, 16538, 0, 0
                    , 260, 15, 0, 0, 77, '2024-12-20 18:43:03')
                ON DUPLICATE KEY UPDATE buyprice = 260,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 18:43:03' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16538', '260', '15', '0', 'buyBillController.php', '32816', '', '0', '0');
UPDATE product SET  productBuyPrice = "260" WHERE productId = 16538 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32816 ;
UPDATE product SET productName = 'A314', productDescription = '', productCatId = '6', productBuyPrice = '260.00', productSellAllPrice = '320.00', productSellUnitPrice = '320.00', productSellHalfPrice = '320.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '0A314',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='260',meanbuyprice_withTax='260',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='260'  WHERE productId = '16538';
UPDATE buybilldetail SET  lastbuyprice = 260 , meanbuyprice = 260, lastbuyprice_withDiscount = 260, meanbuyprice_withDiscount = 260
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 260, lastbuyprice_withDiscountAndTax = 260
                where buybilldetailid = 32816;
UPDATE productunit SET proUnitBuyPrice  = 260 * productnumber WHERE productid = 16538;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16537';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16538', '1', '15', '0', '14179', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 18:28:36','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07332', '14179', '5', '16539', '15', '280', '4200', '0', '', '2024-12-20 18:43:03', '16539','','','0','0','0','0','0',null,'280','4200','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 18:28:36', 1, 16539, 0, 0
                    , 280, 15, 0, 0, 77, '2024-12-20 18:43:03')
                ON DUPLICATE KEY UPDATE buyprice = 280,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 18:43:03' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16539', '280', '15', '0', 'buyBillController.php', '32817', '', '0', '0');
UPDATE product SET  productBuyPrice = "280" WHERE productId = 16539 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32817 ;
UPDATE product SET productName = '7332', productDescription = '', productCatId = '5', productBuyPrice = '280.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07332',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '280',lastbuyprice_withDiscount = '280',meanbuyprice = '280',meanbuyprice_withDiscount = '280' , productbuypricereal = '280.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='280',meanbuyprice_withTax='280',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='280'  WHERE productId = '16539';
UPDATE buybilldetail SET  lastbuyprice = 280 , meanbuyprice = 280, lastbuyprice_withDiscount = 280, meanbuyprice_withDiscount = 280
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 280, lastbuyprice_withDiscountAndTax = 280
                where buybilldetailid = 32817;
UPDATE productunit SET proUnitBuyPrice  = 280 * productnumber WHERE productid = 16539;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16538';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16539', '1', '15', '0', '14179', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 18:28:36','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('0A315', '14179', '6', '16540', '15', '400', '6000', '0', '', '2024-12-20 18:43:03', '16540','','','0','0','0','0','0',null,'400','6000','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 18:28:36', 1, 16540, 0, 0
                    , 400, 15, 0, 0, 77, '2024-12-20 18:43:03')
                ON DUPLICATE KEY UPDATE buyprice = 400,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 18:43:03' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16540', '400', '15', '0', 'buyBillController.php', '32818', '', '0', '0');
UPDATE product SET  productBuyPrice = "400" WHERE productId = 16540 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32818 ;
UPDATE product SET productName = 'A315', productDescription = '', productCatId = '6', productBuyPrice = '400.00', productSellAllPrice = '520.00', productSellUnitPrice = '520.00', productSellHalfPrice = '520.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '0A315',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '400',lastbuyprice_withDiscount = '400',meanbuyprice = '400',meanbuyprice_withDiscount = '400' , productbuypricereal = '400.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='400',meanbuyprice_withTax='400',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='400'  WHERE productId = '16540';
UPDATE buybilldetail SET  lastbuyprice = 400 , meanbuyprice = 400, lastbuyprice_withDiscount = 400, meanbuyprice_withDiscount = 400
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where buybilldetailid = 32818;
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 16540;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16539';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16540', '1', '15', '0', '14179', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 18:28:36','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('0A313', '14179', '6', '16541', '15', '400', '6000', '0', '', '2024-12-20 18:43:03', '16541','','','0','0','0','0','0',null,'400','6000','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 18:28:36', 1, 16541, 0, 0
                    , 400, 15, 0, 0, 77, '2024-12-20 18:43:03')
                ON DUPLICATE KEY UPDATE buyprice = 400,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 18:43:03' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16541', '400', '15', '0', 'buyBillController.php', '32819', '', '0', '0');
UPDATE product SET  productBuyPrice = "400" WHERE productId = 16541 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32819 ;
UPDATE product SET productName = 'A313', productDescription = '', productCatId = '6', productBuyPrice = '400.00', productSellAllPrice = '520.00', productSellUnitPrice = '520.00', productSellHalfPrice = '520.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '0A313',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '400',lastbuyprice_withDiscount = '400',meanbuyprice = '400',meanbuyprice_withDiscount = '400' , productbuypricereal = '400.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='400',meanbuyprice_withTax='400',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='400'  WHERE productId = '16541';
UPDATE buybilldetail SET  lastbuyprice = 400 , meanbuyprice = 400, lastbuyprice_withDiscount = 400, meanbuyprice_withDiscount = 400
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where buybilldetailid = 32819;
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 16541;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16540';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16541', '1', '15', '0', '14179', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 18:28:36','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('0A318', '14179', '6', '16542', '15', '310', '4650', '0', '', '2024-12-20 18:43:03', '16542','','','0','0','0','0','0',null,'310','4650','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 18:28:36', 1, 16542, 0, 0
                    , 310, 15, 0, 0, 77, '2024-12-20 18:43:03')
                ON DUPLICATE KEY UPDATE buyprice = 310,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 18:43:03' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16542', '310', '15', '0', 'buyBillController.php', '32820', '', '0', '0');
UPDATE product SET  productBuyPrice = "310" WHERE productId = 16542 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32820 ;
UPDATE product SET productName = 'A318', productDescription = '', productCatId = '6', productBuyPrice = '310.00', productSellAllPrice = '410.00', productSellUnitPrice = '410.00', productSellHalfPrice = '410.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '0A318',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '310',lastbuyprice_withDiscount = '310',meanbuyprice = '310',meanbuyprice_withDiscount = '310' , productbuypricereal = '310.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='310',meanbuyprice_withTax='310',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='310'  WHERE productId = '16542';
UPDATE buybilldetail SET  lastbuyprice = 310 , meanbuyprice = 310, lastbuyprice_withDiscount = 310, meanbuyprice_withDiscount = 310
        , lastbuyprice_withTax = 310, meanbuyprice_withTax = 310, lastbuyprice_withDiscountAndTax = 310
                where buybilldetailid = 32820;
UPDATE productunit SET proUnitBuyPrice  = 310 * productnumber WHERE productid = 16542;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16541';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16542', '1', '15', '0', '14179', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 18:28:36','0','0');
UPDATE supplier SET  suppliercurrentDebt = '348270',suppliercurrentDebtInCurrency= '348270' , userid = '77', supplierdate = '2024-12-20 18:43:03'   WHERE supplierid = '175';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('175', '311295.00', '36975', '0', 'اضافة فاتورة مشتريات', '14179', '348270', '2024-12-20 18:28:36', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','36975','1','311295','36975','348270','0');
update buybill set dailyentryid='0,' where buybillid=14179;
COMMIT;
UPDATE product SET overAllAveragePrice = 295 WHERE productId = 16536;UPDATE product SET overAllAveragePrice = 520 WHERE productId = 16537;UPDATE product SET overAllAveragePrice = 260 WHERE productId = 16538;UPDATE product SET overAllAveragePrice = 280 WHERE productId = 16539;UPDATE product SET overAllAveragePrice = 400 WHERE productId = 16540;UPDATE product SET overAllAveragePrice = 400 WHERE productId = 16541;UPDATE product SET overAllAveragePrice = 310 WHERE productId = 16542;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:13:04";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:43:04", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:43:04', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14179');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:13:11";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:43:11", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-20 18:43:11', '77', 'showbarcodebuybill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14179&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:14:13";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:44:13", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:44:13', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659e87a0388
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:42:47', '067659e87a0388', '1', '0.00', '0', '0', '1', '500.00', '500', '500', '0', '1', '2024-12-20 18:44:13', '', '9', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','500','0','','0','0','500','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150480', '0', '2024-12-20 18:44:13', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '500', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 18:42:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36418;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('340','H1667', '150480', '14', '16404', '1', '500', '500', '0', '', '1', '2024-12-20 18:44:13', '16404', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36418-1,','1','1','0','0','500','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 340.00 , meanbuyprice = 340.00, lastbuyprice_withDiscount = 340.00, meanbuyprice_withDiscount = 340.00
        , lastbuyprice_withTax = 340, meanbuyprice_withTax = 340, lastbuyprice_withDiscountAndTax = 340
                where sellbilldetailid = 549845;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16404, '2024-12-20', 500, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+340
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 500, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+340
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '9', storedetaildate = '2024-12-20 18:44:13' WHERE storedetailid = '16403';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16404', '1', '1', '1', '150480', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '9', '2024-12-20 18:44:13','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '13295',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('12795','500', '0', '1', 'اضافة فاتورة مبيعات', '150480', '13295', '2024-12-20 18:44:13', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 500, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+340
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 500, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+340
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+340
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 500, 340, 340
                    , 340, 340, 340, 340, 340, 340)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+500, netSellCostBuyPrice = netSellCostBuyPrice+340
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+340
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+340
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+340
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+340
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+340
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+340
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+340;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659e87a0388 and sellbillId = 150480 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:14:13";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 18:44:13", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:44:13', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:15:06";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:45:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 18:45:06', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:15:12";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:45:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:45:12', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:15:28";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:45:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:45:28', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:16:25";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:46:25", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:46:25', '77', '', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:16:33";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:46:33", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:46:33', '2', 'editsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150250');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:16:50";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:46:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:46:50', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:17:27";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:47:27", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:47:27', '2', 'update', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 150250 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 150250 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150250;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 18:47:27', userid = '75',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '150250';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 32069;
UPDATE sellbilldetail SET  lastbuyprice = 340.00 , meanbuyprice = 340.00, lastbuyprice_withDiscount = 340.00, meanbuyprice_withDiscount = 340.00
        
                where sellbilldetailid = 548961;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14429, '2024-12-20', 300, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-300, sellCostBuyPrice =sellCostBuyPrice-340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-340, sellCostMeanBuyPrice = sellCostMeanBuyPrice-340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-300, sellCostBuyPrice =sellCostBuyPrice-340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-340, sellCostMeanBuyPrice = sellCostMeanBuyPrice-340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '1', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '14428';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14429', '1', '1', '0', '150250', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '2', '2024-12-19 16:05:02','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        
                where sellbilldetailid = 548962;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13818, '2024-12-20', 190, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-190, sellCostBuyPrice =sellCostBuyPrice-300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-300, sellCostMeanBuyPrice = sellCostMeanBuyPrice-300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 190, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-190, sellCostBuyPrice =sellCostBuyPrice-300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-300, sellCostMeanBuyPrice = sellCostMeanBuyPrice-300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '1', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '13817';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13818', '1', '1', '0', '150250', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '2', '2024-12-19 16:05:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 35873;
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 548963;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15995, '2024-12-20', 960, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-960, sellCostBuyPrice =sellCostBuyPrice-840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-840, sellCostMeanBuyPrice = sellCostMeanBuyPrice-840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-840
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-2
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 960, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-960, sellCostBuyPrice =sellCostBuyPrice-840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-840, sellCostMeanBuyPrice = sellCostMeanBuyPrice-840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-840
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '33', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '2', '0', '150250', 'تعديل فاتورة مبيعات', 'sellbillController.php', '31', '33', '2', '2024-12-19 16:05:02','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 255.00 , meanbuyprice = 255.00, lastbuyprice_withDiscount = 255.00, meanbuyprice_withDiscount = 255.00
        
                where sellbilldetailid = 548964;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14845, '2024-12-20', 185, 255, 255
                    , 255, 255, 255, 255
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-185, sellCostBuyPrice =sellCostBuyPrice-255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-255, sellCostMeanBuyPrice = sellCostMeanBuyPrice-255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-255
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 185, 255, 255
                    , 255, 255, 255, 255
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-185, sellCostBuyPrice =sellCostBuyPrice-255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-255, sellCostMeanBuyPrice = sellCostMeanBuyPrice-255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-255
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '0', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '14844';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14845', '1', '1', '0', '150250', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-1', '0', '2', '2024-12-19 16:05:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 33783;
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 495.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 495.00
        
                where sellbilldetailid = 548965;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15170, '2024-12-20', 480, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-480, sellCostBuyPrice =sellCostBuyPrice-495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-495, sellCostMeanBuyPrice = sellCostMeanBuyPrice-495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 480, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-480, sellCostBuyPrice =sellCostBuyPrice-495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-495, sellCostMeanBuyPrice = sellCostMeanBuyPrice-495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '5', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '15169';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15170', '1', '1', '0', '150250', 'تعديل فاتورة مبيعات', 'sellbillController.php', '4', '5', '2', '2024-12-19 16:05:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36150;
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 548966;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16279, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-400, sellCostBuyPrice =sellCostBuyPrice-335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-335, sellCostMeanBuyPrice = sellCostMeanBuyPrice-335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-323
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-400, sellCostBuyPrice =sellCostBuyPrice-335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-335, sellCostMeanBuyPrice = sellCostMeanBuyPrice-335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-323
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '56', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '0', '150250', 'تعديل فاتورة مبيعات', 'sellbillController.php', '55', '56', '2', '2024-12-19 16:05:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 32694;
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 495.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 495.00
        
                where sellbilldetailid = 548967;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14736, '2024-12-20', 420, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-495, sellCostMeanBuyPrice = sellCostMeanBuyPrice-495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-495, sellCostMeanBuyPrice = sellCostMeanBuyPrice-495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '3', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '14735';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14736', '1', '1', '0', '150250', 'تعديل فاتورة مبيعات', 'sellbillController.php', '2', '3', '2', '2024-12-19 16:05:02','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        
                where sellbilldetailid = 548968;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10355, '2024-12-20', 150, 150, 150
                    , 150, 150, 150, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-150, sellCostBuyPrice =sellCostBuyPrice-150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-150, sellCostMeanBuyPrice = sellCostMeanBuyPrice-150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 150, 150, 150
                    , 150, 150, 150, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-150, sellCostBuyPrice =sellCostBuyPrice-150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-150, sellCostMeanBuyPrice = sellCostMeanBuyPrice-150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-113', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '10354';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10355', '1', '1', '0', '150250', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-114', '-113', '2', '2024-12-19 16:05:02','0','0');
CALL clientInUse(6484,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '2' WHERE clientid = '6484';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6484','3136.00','3136.00','1','تعديل فاتورة مبيعات','150250', '0', '2024-12-19 16:05:02', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '3136', '0', null, '0', null, null,'', '0','1','1','3136','1','2024-12-19 16:05:02','0','0');
UPDATE client SET  inUse = 0 where clientid = 6484;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 3136, 3210, 3210
                    , 3210, 3210, 3210, 3060
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1175, 1163, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-3136, sellCostBuyPrice =sellCostBuyPrice-3210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-3210, sellCostMeanBuyPrice = sellCostMeanBuyPrice-3210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-3210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-3210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-3060
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1175
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1163
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6484, '2024-12-20', 3136, 3210, 3210
                    , 3210, 3210, 3210, 3060
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1175, 1163, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-3136, sellCostBuyPrice =sellCostBuyPrice-3210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-3210, sellCostMeanBuyPrice = sellCostMeanBuyPrice-3210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-3210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-3210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-3060
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1175
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1163
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3136, 3210, 3210
                    , 3210, 3210, 3210, 3060, 1175, 1163)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-3136, netSellCostBuyPrice = netSellCostBuyPrice-3210
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-3210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-3210
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-3210
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-3210
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-3060
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-1175
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-1163;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 150250 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 150250 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(6484,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-19 16:05:02', '06764280e03aa9', '6484', '0.00', '2121', '0', '1', '2121', '2121', '0', '2121', '1', '2024-12-19 16:05:02', '', '2', '0', 'سارة عبد الناصر D13', '2', '1', '3', '81', 'سارة عبد الناصر D13', '8', '150250', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-19','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2121', userid = '2' WHERE clientid = '6484';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6484','0.00','2121','0','اضافة فاتورة مبيعات (معدله)','150481', '2121', '2024-12-20 18:47:27', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '2121', '0', null, '0', null, null,'', '0','1','1','3136','1','2024-12-19 16:05:02','0','0');
UPDATE client SET  inUse = 0 where clientid = 6484;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32069;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('340','06349', '150481', '5', '14429', '1', '300', '300', '0', '', '1', '2024-12-20 18:47:27', '14429', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32069-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 340.00 , meanbuyprice = 340.00, lastbuyprice_withDiscount = 340.00, meanbuyprice_withDiscount = 340.00
        
                where sellbilldetailid = 549846;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14429, '2024-12-20', 300, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+340
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '14428';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14429', '1', '1', '1', '150481', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '1', '0', '2', '2024-12-20 18:47:27','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('300','R2781', '150481', '1', '13818', '1', '190', '190', '0', '', '1', '2024-12-20 18:47:27', '13818', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','190','190','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        
                where sellbilldetailid = 549847;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13818, '2024-12-20', 190, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 190, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '13817';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13818', '1', '1', '1', '150481', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '1', '0', '2', '2024-12-20 18:47:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35873;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('420','07037', '150481', '5', '15995', '2', '480', '960', '0', '', '1', '2024-12-20 18:47:27', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35873-2,','1','1','0','0','480','960','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where sellbilldetailid = 549848;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15995, '2024-12-20', 960, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+960, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 960, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+960, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '31', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '2', '1', '150481', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '33', '31', '2', '2024-12-20 18:47:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33783;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('495','06683', '150481', '5', '15170', '1', '480', '480', '0', '', '1', '2024-12-20 18:47:27', '15170', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33783-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 495.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 495.00
        
                where sellbilldetailid = 549849;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15170, '2024-12-20', 480, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 480, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '15169';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15170', '1', '1', '1', '150481', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '5', '4', '2', '2024-12-20 18:47:27','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('150','عرض 150', '150481', '18', '10355', '1', '150', '150', '0', '', '1', '2024-12-20 18:47:27', '10355', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','150','150','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        
                where sellbilldetailid = 549850;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10355, '2024-12-20', 150, 150, 150
                    , 150, 150, 150, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 150, 150, 150
                    , 150, 150, 150, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-114', userid = '2', storedetaildate = '2024-12-20 18:47:27' WHERE storedetailid = '10354';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10355', '1', '1', '1', '150481', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '-113', '-114', '2', '2024-12-20 18:47:27','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150481', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 18:47:27', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150481', '17', '10291', '1', '21', '21', '0', '', '1', '2024-12-20 18:47:27', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','21','21','0','','0','0.00','0','0','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2121, 2125, 2125
                    , 2125, 2125, 2125, 1975
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2121, sellCostBuyPrice =sellCostBuyPrice+2125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1975
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6484, '2024-12-20', 2121, 2125, 2125
                    , 2125, 2125, 2125, 1975
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2121, sellCostBuyPrice =sellCostBuyPrice+2125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1975
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2121, 2125, 2125
                    , 2125, 2125, 2125, 1975, 840, 840)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2121, netSellCostBuyPrice = netSellCostBuyPrice+2125
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2125
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2125
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2125
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2125
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1975
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+840
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+840;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150250 and newid=150481 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:17:28";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:47:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 18:47:28', '2', 'editprint', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150481');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:17:43";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:47:43", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:47:43', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:17:52";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:47:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 18:47:52', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:18:30";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:48:30", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-20 18:48:30', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:22:19";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:52:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:52:19', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248072
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6484,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-1015' , clientdate = '2024-12-20 18:52:19', userid = '2' WHERE clientid = '6484';
UPDATE client SET  inUse = 0 where clientid = 6484;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6484','2121.00','3136','1','ايصال تحصيل (( قبض من عميل ))','248072', '-1015', '2024-12-20 18:32:45', '2', 'clientPayedDeptController.php', '   ', '3136', '0', null, '0', null, null,'', '-1','1','1','3136','1','','3675','0');
UPDATE save SET  savecurrentvalue = '167836.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('164700.50','3136', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248082', '167836.5', '2024-12-20 18:52:19', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '3136', '3136', '2024-12-20', '2', '0', '0', '2024-12-20 18:52:20','اضافة ايصال سداد للعميل سارة عبد الناصر D13','1','0','0','0','248082','clientPayedDeptController.php?do=show&id=248082');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122343', '-1', '3136', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '3136', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122343', '-1', '3136', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-3136', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '6484', clientdebtchangebefore = '2121.000', clientdebtchangeamount = '3136.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248072', clientdebtchangeafter = '-1015.000', clientdebtchangedate = '2024-12-20 18:32:45', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '3136.00',discount='', reciptid='0', dailyentryid = '122343',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='3136',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248082';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248072 -clientdebtchangeId = 248082
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:22:20";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:52:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:52:20', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:22:51";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:52:51", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:52:51', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248083
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9047,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 18:52:51', userid = '2' WHERE clientid = '9047';
UPDATE client SET  inUse = 0 where clientid = 9047;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9047','3739.00','3739','1','ايصال تحصيل (( قبض من عميل ))','248083', '0', '2024-12-20 18:52:21', '2', 'clientPayedDeptController.php', '   ', '3739', '0', null, '0', null, null,'', '-1','1','1','3739','1','','3676','0');
UPDATE save SET  savecurrentvalue = '171575.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('167836.50','3739', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248083', '171575.5', '2024-12-20 18:52:51', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '3739', '3739', '2024-12-20', '2', '0', '0', '2024-12-20 18:52:51','اضافة ايصال سداد للعميل مي السويس  B503','1','0','0','0','248083','clientPayedDeptController.php?do=show&id=248083');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122344', '-1', '3739', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '3739', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122344', '-1', '3739', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-3739', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '9047', clientdebtchangebefore = '3739.000', clientdebtchangeamount = '3739.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248083', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 18:52:21', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '3739.00',discount='', reciptid='0', dailyentryid = '122344',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='3739',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248083';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248083 -clientdebtchangeId = 248083
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:22:52";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:52:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:52:52', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:23:11";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:53:11", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:53:11', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248084
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10779,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 18:53:11', userid = '2' WHERE clientid = '10779';
UPDATE client SET  inUse = 0 where clientid = 10779;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10779','1630.00','1630','1','ايصال تحصيل (( قبض من عميل ))','248084', '0', '2024-12-20 18:52:52', '2', 'clientPayedDeptController.php', '   ', '1630', '0', null, '0', null, null,'', '-1','1','1','1630','1','','3677','0');
UPDATE save SET  savecurrentvalue = '173205.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('171575.50','1630', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248084', '173205.5', '2024-12-20 18:53:11', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1630', '1630', '2024-12-20', '2', '0', '0', '2024-12-20 18:53:11','اضافة ايصال سداد للعميل فاطمه يوسف','1','0','0','0','248084','clientPayedDeptController.php?do=show&id=248084');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122345', '-1', '1630', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1630', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122345', '12625', '1630', '','0');
UPDATE accountstree SET name = 'فاطمه يوسف', customName = 'فاطمه يوسف', customNameEn = 'فاطمه يوسف', nameEn = 'فاطمه يوسف', parent = '58', accountNature = '0', theValue = '-1630', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '9', del = '0', sysdate = '2024-12-20 18:39:19' WHERE id = '12625';
UPDATE clientdebtchange SET clientid = '10779', clientdebtchangebefore = '1630.000', clientdebtchangeamount = '1630.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248084', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 18:52:52', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1630.00',discount='', reciptid='0', dailyentryid = '122345',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1630',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248084';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248084 -clientdebtchangeId = 248084
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:23:12";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:53:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:53:12', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:23:28";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:53:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:53:28', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248085
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1834,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-1' , clientdate = '2024-12-20 18:53:28', userid = '2' WHERE clientid = '1834';
UPDATE client SET  inUse = 0 where clientid = 1834;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1834','276.00','277','1','ايصال تحصيل (( قبض من عميل ))','248085', '-1', '2024-12-20 18:53:12', '2', 'clientPayedDeptController.php', '   ', '277', '0', null, '0', null, null,'', '-1','1','1','277','1','','3678','0');
UPDATE save SET  savecurrentvalue = '173482.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('173205.50','277', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248085', '173482.5', '2024-12-20 18:53:28', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('وفاء الموجي d103', 'وفاء الموجي d103', 'وفاء الموجي d103', 'وفاء الموجي d103', '58', '0', '-1.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 18:53:28');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '277', '277', '2024-12-20', '2', '0', '0', '2024-12-20 18:53:28','اضافة ايصال سداد للعميل وفاء الموجي d103','1','0','0','0','248085','clientPayedDeptController.php?do=show&id=248085');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122346', '-1', '277', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '277', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122346', '12626', '277', '','0');
UPDATE accountstree SET name = 'وفاء الموجي d103', customName = 'وفاء الموجي d103', customNameEn = 'وفاء الموجي d103', nameEn = 'وفاء الموجي d103', parent = '58', accountNature = '0', theValue = '-278', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 18:53:28' WHERE id = '12626';
UPDATE clientdebtchange SET clientid = '1834', clientdebtchangebefore = '276.000', clientdebtchangeamount = '277.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248085', clientdebtchangeafter = '-1.000', clientdebtchangedate = '2024-12-20 18:53:12', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '277.00',discount='', reciptid='0', dailyentryid = '122346',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='277',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248085';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248085 -clientdebtchangeId = 248085
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:23:29";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:53:29", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:53:29', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:23:44";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:53:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:53:44', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248086
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(97,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 18:53:44', userid = '2' WHERE clientid = '97';
UPDATE client SET  inUse = 0 where clientid = 97;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('97','455.00','455','1','ايصال تحصيل (( قبض من عميل ))','248086', '0', '2024-12-20 18:53:29', '2', 'clientPayedDeptController.php', '   ', '455', '0', null, '0', null, null,'', '-1','1','1','455','1','','3679','0');
UPDATE save SET  savecurrentvalue = '173937.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('173482.50','455', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248086', '173937.5', '2024-12-20 18:53:44', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('مروة عبد الرحيم', 'مروة عبد الرحيم', 'مروة عبد الرحيم', 'مروة عبد الرحيم', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-20 18:53:44');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '455', '455', '2024-12-20', '2', '0', '0', '2024-12-20 18:53:44','اضافة ايصال سداد للعميل مروة عبد الرحيم','1','0','0','0','248086','clientPayedDeptController.php?do=show&id=248086');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122347', '-1', '455', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '455', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122347', '12627', '455', '','0');
UPDATE accountstree SET name = 'مروة عبد الرحيم', customName = 'مروة عبد الرحيم', customNameEn = 'مروة عبد الرحيم', nameEn = 'مروة عبد الرحيم', parent = '58', accountNature = '0', theValue = '-455', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-20 18:53:44' WHERE id = '12627';
UPDATE clientdebtchange SET clientid = '97', clientdebtchangebefore = '455.000', clientdebtchangeamount = '455.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248086', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 18:53:29', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '455.00',discount='', reciptid='0', dailyentryid = '122347',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='455',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248086';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248086 -clientdebtchangeId = 248086
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:23:45";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:53:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:53:45', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:24:05";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:54:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:54:05', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248087
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6167,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '40' , clientdate = '2024-12-20 18:54:05', userid = '2' WHERE clientid = '6167';
UPDATE client SET  inUse = 0 where clientid = 6167;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6167','565.00','525','1','ايصال تحصيل (( قبض من عميل ))','248087', '40', '2024-12-20 18:53:45', '2', 'clientPayedDeptController.php', '   ', '525', '0', null, '0', null, null,'', '-1','1','1','525','1','','3680','0');
UPDATE save SET  savecurrentvalue = '174462.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('173937.50','525', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248087', '174462.5', '2024-12-20 18:54:05', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '525', '525', '2024-12-20', '2', '0', '0', '2024-12-20 18:54:05','اضافة ايصال سداد للعميل الاء يسري 73','1','0','0','0','248087','clientPayedDeptController.php?do=show&id=248087');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122348', '-1', '525', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '525', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122348', '-1', '525', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-525', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '6167', clientdebtchangebefore = '565.000', clientdebtchangeamount = '525.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248087', clientdebtchangeafter = '40.000', clientdebtchangedate = '2024-12-20 18:53:45', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '525.00',discount='', reciptid='0', dailyentryid = '122348',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='525',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248087';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248087 -clientdebtchangeId = 248087
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:24:06";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:54:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:54:06', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:24:37";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:54:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:54:37', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248088
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10757,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 18:54:37', userid = '2' WHERE clientid = '10757';
UPDATE client SET  inUse = 0 where clientid = 10757;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10757','1232.00','1232','1','ايصال تحصيل (( قبض من عميل ))','248088', '0', '2024-12-20 18:54:06', '2', 'clientPayedDeptController.php', '   ', '1232', '0', null, '0', null, null,'', '-1','1','1','1232','1','','3681','0');
UPDATE save SET  savecurrentvalue = '175694.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('174462.50','1232', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248088', '175694.5', '2024-12-20 18:54:37', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1232', '1232', '2024-12-20', '2', '0', '0', '2024-12-20 18:54:37','اضافة ايصال سداد للعميل مريم زاهر 25','1','0','0','0','248088','clientPayedDeptController.php?do=show&id=248088');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122349', '-1', '1232', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1232', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122349', '12587', '1232', '','0');
UPDATE accountstree SET name = 'مريم زاهر 25', customName = 'مريم زاهر 25', customNameEn = 'مريم زاهر 25', nameEn = 'مريم زاهر 25', parent = '58', accountNature = '0', theValue = '-1232', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-19 15:49:47' WHERE id = '12587';
UPDATE clientdebtchange SET clientid = '10757', clientdebtchangebefore = '1232.000', clientdebtchangeamount = '1232.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248088', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 18:54:06', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1232.00',discount='', reciptid='0', dailyentryid = '122349',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1232',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248088';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248088 -clientdebtchangeId = 248088
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:24:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:54:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:54:38', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:24:56";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:54:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:54:56', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248089
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4241,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '487' , clientdate = '2024-12-20 18:54:56', userid = '2' WHERE clientid = '4241';
UPDATE client SET  inUse = 0 where clientid = 4241;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4241','1072.00','585','1','ايصال تحصيل (( قبض من عميل ))','248089', '487', '2024-12-20 18:54:38', '2', 'clientPayedDeptController.php', '   ', '585', '0', null, '0', null, null,'', '-1','1','1','585','1','','3682','0');
UPDATE save SET  savecurrentvalue = '176279.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('175694.50','585', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248089', '176279.5', '2024-12-20 18:54:56', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '585', '585', '2024-12-20', '2', '0', '0', '2024-12-20 18:54:56','اضافة ايصال سداد للعميل بسنت عادل 25','1','0','0','0','248089','clientPayedDeptController.php?do=show&id=248089');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122350', '-1', '585', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '585', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122350', '-1', '585', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-585', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '4241', clientdebtchangebefore = '1072.000', clientdebtchangeamount = '585.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248089', clientdebtchangeafter = '487.000', clientdebtchangedate = '2024-12-20 18:54:38', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '585.00',discount='', reciptid='0', dailyentryid = '122350',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='585',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248089';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248089 -clientdebtchangeId = 248089
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:24:56";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:54:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 18:54:56', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:25:14";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:55:14", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:55:14', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE productunit SET unitid = '1', productid = '15038', productnumber = '1.00', productunitdate = '2024-09-14', userid = '77', conditions = '0',proUnitParcode='1503801',proUnitSellAllPrice='300',proUnitSellHalfPrice='300',proUnitSellUnitPrice ='300',proUnitBuyPrice='225',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '15038';
UPDATE product SET productName = '6603', productDescription = '', productCatId = '5', productBuyPrice = '230', productSellAllPrice = '290', productSellUnitPrice = '290', productSellHalfPrice = '290', productDate = '2024-09-14', conditions = '0', userId = '77', limitamount = '0', parcode = '06603',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '228',meanbuyprice_withDiscount = '228' , productbuypricereal = '230' , buypricereal_precentage = '0' , buytotal_precentage = '25' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='235.95',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='225',meanbuyprice_withTax='227',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='225'  WHERE productId = '15038';
UPDATE productunit SET unitid = '1', productid = '16374', productnumber = '1.00', productunitdate = '2024-12-10', userid = '77', conditions = '0',proUnitParcode='1637401',proUnitSellAllPrice='300',proUnitSellHalfPrice='300',proUnitSellUnitPrice ='300',proUnitBuyPrice='225',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16374';
UPDATE product SET productName = '7260', productDescription = '', productCatId = '5', productBuyPrice = '230', productSellAllPrice = '300', productSellUnitPrice = '300', productSellHalfPrice = '300', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07260',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '230.5',meanbuyprice_withDiscount = '230.5' , productbuypricereal = '250' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='237.5',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='225',meanbuyprice_withTax='238',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='225'  WHERE productId = '16374';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:27:04";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:57:04", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:57:04', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a17288876', '2024-12-20 18:55:14', '246', '15150.00', '32400', '0', '0', '17250',  '17250', '0', '17250', '1', '2024-12-20 18:57:04', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06603', '14180', '5', '15038', '30', '230', '6900', '0', '', '2024-12-20 18:57:04', '15038','','','0','0','0','0','0',null,'230','6900','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 18:55:14', 1, 15038, 0, 0
                    , 230, 30, 0, 0, 77, '2024-12-20 18:57:04')
                ON DUPLICATE KEY UPDATE buyprice = 230,
                        buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 18:57:04' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15038', '230', '30', '0', 'buyBillController.php', '32821', '', '0', '0');
UPDATE product SET  productBuyPrice = "230" WHERE productId = 15038 ;
UPDATE buybilldetail SET  quantitybefore = 41 WHERE buybilldetailid = 32821 ;
UPDATE product SET productName = '6603', productDescription = '', productCatId = '5', productBuyPrice = '230.00', productSellAllPrice = '290.00', productSellUnitPrice = '290.00', productSellHalfPrice = '290.00', productDate = '2024-09-14', conditions = '0', userId = '77', limitamount = '0', parcode = '06603',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '230',lastbuyprice_withDiscount = '230',meanbuyprice = '229',meanbuyprice_withDiscount = '229' , productbuypricereal = '230.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '25.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='235.95',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='230',meanbuyprice_withTax='228',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='230'  WHERE productId = '15038';
UPDATE buybilldetail SET  lastbuyprice = 230 , meanbuyprice = 229, lastbuyprice_withDiscount = 230, meanbuyprice_withDiscount = 229
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 228, lastbuyprice_withDiscountAndTax = 230
                where buybilldetailid = 32821;
UPDATE productunit SET proUnitBuyPrice  = 230 * productnumber WHERE productid = 15038;
UPDATE storedetail SET  productquantity = '71', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '30', '0', '14180', 'اضافة فاتورة مشتريات', 'buyBillController.php', '41', '71', '77', '2024-12-20 18:55:14','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07260', '14180', '5', '16374', '45', '230', '10350', '0', '', '2024-12-20 18:57:04', '16374','','','0','0','0','0','0',null,'230','10350','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 18:55:14', 1, 16374, 0, 0
                    , 230, 45, 0, 0, 77, '2024-12-20 18:57:04')
                ON DUPLICATE KEY UPDATE buyprice = 230,
                        buyQuantity =buyQuantity+45, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 18:57:04' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16374', '230', '45', '0', 'buyBillController.php', '32822', '', '0', '0');
UPDATE product SET  productBuyPrice = "230" WHERE productId = 16374 ;
UPDATE buybilldetail SET  quantitybefore = 11 WHERE buybilldetailid = 32822 ;
UPDATE product SET productName = '7260', productDescription = '', productCatId = '5', productBuyPrice = '230.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07260',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '230',lastbuyprice_withDiscount = '230',meanbuyprice = '230',meanbuyprice_withDiscount = '230' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='237.5',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='230',meanbuyprice_withTax='232',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='230'  WHERE productId = '16374';
UPDATE buybilldetail SET  lastbuyprice = 230 , meanbuyprice = 230, lastbuyprice_withDiscount = 230, meanbuyprice_withDiscount = 230
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 232, lastbuyprice_withDiscountAndTax = 230
                where buybilldetailid = 32822;
UPDATE productunit SET proUnitBuyPrice  = 230 * productnumber WHERE productid = 16374;
UPDATE storedetail SET  productquantity = '56', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16374', '1', '45', '0', '14180', 'اضافة فاتورة مشتريات', 'buyBillController.php', '11', '56', '77', '2024-12-20 18:55:14','0','0');
UPDATE supplier SET  suppliercurrentDebt = '32400',suppliercurrentDebtInCurrency= '32400' , userid = '77', supplierdate = '2024-12-20 18:57:04'   WHERE supplierid = '246';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('246', '15150.00', '17250', '0', 'اضافة فاتورة مشتريات', '14180', '32400', '2024-12-20 18:55:14', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','17250','1','15150','17250','32400','0');
update buybill set dailyentryid='0,' where buybillid=14180;
COMMIT;
UPDATE product SET overAllAveragePrice = 235.43 WHERE productId = 15038;UPDATE product SET overAllAveragePrice = 233 WHERE productId = 16374;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:27:05";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:57:05", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:57:05', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14180');
UPDATE user SET loginip = "" WHERE userid = 75;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:28:02";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:58:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 18:58:02', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:28:30";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 18:58:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 18:58:30', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:28:31";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:58:31", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:58:31', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:28:56";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:58:56", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:58:56', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a2377b8e9', '2024-12-20 18:58:31', '52', '113795.00', '125595', '0', '0', '11800',  '11800', '0', '11800', '1', '2024-12-20 18:58:56', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06870', '14181', '5', '15653', '40', '295', '11800', '0', '', '2024-12-20 18:58:56', '15653','','','0','0','0','0','0',null,'295','11800','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 18:58:31', 1, 15653, 0, 0
                    , 295, 40, 0, 0, 77, '2024-12-20 18:58:56')
                ON DUPLICATE KEY UPDATE buyprice = 295,
                        buyQuantity =buyQuantity+40, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 18:58:56' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15653', '295', '40', '0', 'buyBillController.php', '32823', '', '0', '0');
UPDATE product SET  productBuyPrice = "295" WHERE productId = 15653 ;
UPDATE buybilldetail SET  quantitybefore = 23 WHERE buybilldetailid = 32823 ;
UPDATE product SET productName = 'كوتشي6870', productDescription = '', productCatId = '5', productBuyPrice = '295.00', productSellAllPrice = '360.00', productSellUnitPrice = '360.00', productSellHalfPrice = '360.00', productDate = '2024-10-24', conditions = '0', userId = '77', limitamount = '0', parcode = '06870',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '295',lastbuyprice_withDiscount = '295',meanbuyprice = '299',meanbuyprice_withDiscount = '299' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='295',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',barcodeInTax='',productNameE='',partNumber='0',vehicleType='-1',company='-1',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='295',meanbuyprice_withTax='299',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='295'  WHERE productId = '15653';
UPDATE buybilldetail SET  lastbuyprice = 295 , meanbuyprice = 299, lastbuyprice_withDiscount = 295, meanbuyprice_withDiscount = 299
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 299, lastbuyprice_withDiscountAndTax = 295
                where buybilldetailid = 32823;
UPDATE productunit SET proUnitBuyPrice  = 295 * productnumber WHERE productid = 15653;
UPDATE storedetail SET  productquantity = '63', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '15652';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15653', '1', '40', '0', '14181', 'اضافة فاتورة مشتريات', 'buyBillController.php', '23', '63', '77', '2024-12-20 18:58:31','0','0');
UPDATE supplier SET  suppliercurrentDebt = '125595',suppliercurrentDebtInCurrency= '125595' , userid = '77', supplierdate = '2024-12-20 18:58:56'   WHERE supplierid = '52';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('52', '113795.00', '11800', '0', 'اضافة فاتورة مشتريات', '14181', '125595', '2024-12-20 18:58:31', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','11800','1','113795','11800','125595','0');
update buybill set dailyentryid='0,' where buybillid=14181;
COMMIT;
UPDATE product SET overAllAveragePrice = 295 WHERE productId = 15653;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:28:57";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:58:57", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:58:57', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14181');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:29:32";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:59:32", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:59:32', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:29:57";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:59:57", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:59:57', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a27460a89', '2024-12-20 18:59:32', '52', '125595.00', '137395', '0', '0', '11800',  '11800', '0', '11800', '1', '2024-12-20 18:59:57', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06872', '14182', '5', '15654', '40', '295', '11800', '0', '', '2024-12-20 18:59:57', '15654','','','0','0','0','0','0',null,'295','11800','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 18:59:32', 1, 15654, 0, 0
                    , 295, 40, 0, 0, 77, '2024-12-20 18:59:57')
                ON DUPLICATE KEY UPDATE buyprice = 295,
                        buyQuantity =buyQuantity+40, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 18:59:57' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15654', '295', '40', '0', 'buyBillController.php', '32824', '', '0', '0');
UPDATE product SET  productBuyPrice = "295" WHERE productId = 15654 ;
UPDATE buybilldetail SET  quantitybefore = 3 WHERE buybilldetailid = 32824 ;
UPDATE product SET productName = '6872', productDescription = '', productCatId = '5', productBuyPrice = '295.00', productSellAllPrice = '360.00', productSellUnitPrice = '360.00', productSellHalfPrice = '360.00', productDate = '2024-10-24', conditions = '0', userId = '77', limitamount = '0', parcode = '06872',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '295',lastbuyprice_withDiscount = '295',meanbuyprice = '299',meanbuyprice_withDiscount = '299' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='295',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='295',meanbuyprice_withTax='299',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='295'  WHERE productId = '15654';
UPDATE buybilldetail SET  lastbuyprice = 295 , meanbuyprice = 299, lastbuyprice_withDiscount = 295, meanbuyprice_withDiscount = 299
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 299, lastbuyprice_withDiscountAndTax = 295
                where buybilldetailid = 32824;
UPDATE productunit SET proUnitBuyPrice  = 295 * productnumber WHERE productid = 15654;
UPDATE storedetail SET  productquantity = '43', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '40', '0', '14182', 'اضافة فاتورة مشتريات', 'buyBillController.php', '3', '43', '77', '2024-12-20 18:59:32','0','0');
UPDATE supplier SET  suppliercurrentDebt = '137395',suppliercurrentDebtInCurrency= '137395' , userid = '77', supplierdate = '2024-12-20 18:59:57'   WHERE supplierid = '52';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('52', '125595.00', '11800', '0', 'اضافة فاتورة مشتريات', '14182', '137395', '2024-12-20 18:59:32', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','11800','1','125595','11800','137395','0');
update buybill set dailyentryid='0,' where buybillid=14182;
COMMIT;
UPDATE product SET overAllAveragePrice = 295 WHERE productId = 15654;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:29:58";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 18:59:58", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 18:59:58', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14182');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:30:15";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:00:15", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 19:00:15', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:30:27";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:00:27", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 19:00:27', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:31:17";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:01:17", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 19:01:17', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:31:44";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:01:44", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 19:01:44', '9', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', '  خشب باقي 500', '', '2500', '2024-12-20', '9', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '10795',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('13295.00','2500', '1', '1', 'إضافة مصروف', '25914', '10795', '2024-12-20 19:01:44', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = '  خشب باقي 500', expensesdetails = '', expensesValue = '2500.00', expensesdate = '2024-12-20', userid = '9', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25914';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:31:44";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:01:44", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 19:01:44', '9', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:31:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:01:46", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 19:01:46', '9', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:31:54";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:01:54", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:01:54', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('H1702','','14','510','620', '620','620', '2024-12-20', '0', '77', '1', 'H1702', '0', '0', '0', '0', '0', '510','510','510','510','510','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','510','510','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16543, 1,'2024-12-20 19:02:19',77)
                ON DUPLICATE KEY UPDATE productid = 16543, edited = 1, sysdate = '2024-12-20 19:02:19', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16543', '1', '2024-12-20', '77', '0','1654301','620','620','620','510','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16543', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16543', '1', '0', '0', '16543', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:32:27";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:02:27", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:02:27', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a302c64e2', '2024-12-20 19:01:54', '7', '250440.00', '255540', '0', '0', '5100',  '5100', '0', '5100', '1', '2024-12-20 19:02:27', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1702', '14183', '14', '16543', '10', '510', '5100', '0', '', '2024-12-20 19:02:27', '16543','','','0','0','0','0','0',null,'510','5100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:01:54', 1, 16543, 0, 0
                    , 510, 10, 0, 0, 77, '2024-12-20 19:02:27')
                ON DUPLICATE KEY UPDATE buyprice = 510,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:02:27' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16543', '510', '10', '0', 'buyBillController.php', '32825', '', '0', '0');
UPDATE product SET  productBuyPrice = "510" WHERE productId = 16543 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32825 ;
UPDATE product SET productName = 'H1702', productDescription = '', productCatId = '14', productBuyPrice = '510.00', productSellAllPrice = '620.00', productSellUnitPrice = '620.00', productSellHalfPrice = '620.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1702',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '510',lastbuyprice_withDiscount = '510',meanbuyprice = '510',meanbuyprice_withDiscount = '510' , productbuypricereal = '510.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='510',meanbuyprice_withTax='510',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='510'  WHERE productId = '16543';
UPDATE buybilldetail SET  lastbuyprice = 510 , meanbuyprice = 510, lastbuyprice_withDiscount = 510, meanbuyprice_withDiscount = 510
        , lastbuyprice_withTax = 510, meanbuyprice_withTax = 510, lastbuyprice_withDiscountAndTax = 510
                where buybilldetailid = 32825;
UPDATE productunit SET proUnitBuyPrice  = 510 * productnumber WHERE productid = 16543;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16542';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16543', '1', '10', '0', '14183', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-20 19:01:54','0','0');
UPDATE supplier SET  suppliercurrentDebt = '255540',suppliercurrentDebtInCurrency= '255540' , userid = '77', supplierdate = '2024-12-20 19:02:27'   WHERE supplierid = '7';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('7', '250440.00', '5100', '0', 'اضافة فاتورة مشتريات', '14183', '255540', '2024-12-20 19:01:54', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','5100','1','250440','5100','255540','0');
update buybill set dailyentryid='0,' where buybillid=14183;
COMMIT;
UPDATE product SET overAllAveragePrice = 510 WHERE productId = 16543;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:32:28";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:02:28", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:02:28', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14183');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:33:04";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:03:04", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:03:04', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7371','','5','250','310', '310','310', '2024-12-20', '0', '77', '1', '07371', '0', '0', '0', '0', '0', '250','250','250','250','250','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','250','250','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16544, 1,'2024-12-20 19:03:53',77)
                ON DUPLICATE KEY UPDATE productid = 16544, edited = 1, sysdate = '2024-12-20 19:03:53', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16544', '1', '2024-12-20', '77', '0','1654401','310','310','310','250','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16544', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16544', '1', '0', '0', '16544', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:34:01";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:04:01", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:04:01', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a348e41dc', '2024-12-20 19:03:04', '49', '24320.00', '34320', '0', '0', '10000',  '10000', '0', '10000', '1', '2024-12-20 19:04:01', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07371', '14184', '5', '16544', '40', '250', '10000', '0', '', '2024-12-20 19:04:01', '16544','','','0','0','0','0','0',null,'250','10000','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:03:04', 1, 16544, 0, 0
                    , 250, 40, 0, 0, 77, '2024-12-20 19:04:01')
                ON DUPLICATE KEY UPDATE buyprice = 250,
                        buyQuantity =buyQuantity+40, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:04:01' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16544', '250', '40', '0', 'buyBillController.php', '32826', '', '0', '0');
UPDATE product SET  productBuyPrice = "250" WHERE productId = 16544 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32826 ;
UPDATE product SET productName = '7371', productDescription = '', productCatId = '5', productBuyPrice = '250.00', productSellAllPrice = '310.00', productSellUnitPrice = '310.00', productSellHalfPrice = '310.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07371',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '250',lastbuyprice_withDiscount = '250',meanbuyprice = '250',meanbuyprice_withDiscount = '250' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='250',meanbuyprice_withTax='250',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='250'  WHERE productId = '16544';
UPDATE buybilldetail SET  lastbuyprice = 250 , meanbuyprice = 250, lastbuyprice_withDiscount = 250, meanbuyprice_withDiscount = 250
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where buybilldetailid = 32826;
UPDATE productunit SET proUnitBuyPrice  = 250 * productnumber WHERE productid = 16544;
UPDATE storedetail SET  productquantity = '40', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16543';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16544', '1', '40', '0', '14184', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '40', '77', '2024-12-20 19:03:04','0','0');
UPDATE supplier SET  suppliercurrentDebt = '34320',suppliercurrentDebtInCurrency= '34320' , userid = '77', supplierdate = '2024-12-20 19:04:01'   WHERE supplierid = '49';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('49', '24320.00', '10000', '0', 'اضافة فاتورة مشتريات', '14184', '34320', '2024-12-20 19:03:04', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','10000','1','24320','10000','34320','0');
update buybill set dailyentryid='0,' where buybillid=14184;
COMMIT;
UPDATE product SET overAllAveragePrice = 250 WHERE productId = 16544;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:34:01";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:04:01", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:04:01', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14184');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:35:20";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:05:20", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:05:20', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7354','','5','155','210', '210','210', '2024-12-20', '0', '77', '1', '07354', '0', '0', '0', '0', '0', '155','155','155','155','155','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','155','155','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16545, 1,'2024-12-20 19:05:41',77)
                ON DUPLICATE KEY UPDATE productid = 16545, edited = 1, sysdate = '2024-12-20 19:05:41', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16545', '1', '2024-12-20', '77', '0','1654501','210','210','210','155','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16545', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16545', '1', '0', '0', '16545', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7352','','5','175','225', '225','225', '2024-12-20', '0', '77', '1', '07352', '0', '0', '0', '0', '0', '175','175','175','175','175','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','175','175','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16546, 1,'2024-12-20 19:06:23',77)
                ON DUPLICATE KEY UPDATE productid = 16546, edited = 1, sysdate = '2024-12-20 19:06:23', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16546', '1', '2024-12-20', '77', '0','1654601','225','225','225','175','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16546', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16546', '1', '0', '0', '16546', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:36:39";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:06:39", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:06:39', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a3d059959', '2024-12-20 19:05:20', '101', '142610.00', '150185', '0', '0', '7575',  '7575', '0', '7575', '1', '2024-12-20 19:06:39', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07354', '14185', '5', '16545', '15', '155', '2325', '0', '', '2024-12-20 19:06:39', '16545','','','0','0','0','0','0',null,'155','2325','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:05:20', 1, 16545, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-20 19:06:39')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:06:39' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16545', '155', '15', '0', 'buyBillController.php', '32827', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 16545 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32827 ;
UPDATE product SET productName = '7354', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '210.00', productSellUnitPrice = '210.00', productSellHalfPrice = '210.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07354',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '155.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '16545';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32827;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 16545;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16544';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16545', '1', '15', '0', '14185', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:05:20','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07352', '14185', '5', '16546', '30', '175', '5250', '0', '', '2024-12-20 19:06:39', '16546','','','0','0','0','0','0',null,'175','5250','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:05:20', 1, 16546, 0, 0
                    , 175, 30, 0, 0, 77, '2024-12-20 19:06:39')
                ON DUPLICATE KEY UPDATE buyprice = 175,
                        buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:06:39' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16546', '175', '30', '0', 'buyBillController.php', '32828', '', '0', '0');
UPDATE product SET  productBuyPrice = "175" WHERE productId = 16546 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32828 ;
UPDATE product SET productName = '7352', productDescription = '', productCatId = '5', productBuyPrice = '175.00', productSellAllPrice = '225.00', productSellUnitPrice = '225.00', productSellHalfPrice = '225.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07352',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '175',lastbuyprice_withDiscount = '175',meanbuyprice = '175',meanbuyprice_withDiscount = '175' , productbuypricereal = '175.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='175',meanbuyprice_withTax='175',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='175'  WHERE productId = '16546';
UPDATE buybilldetail SET  lastbuyprice = 175 , meanbuyprice = 175, lastbuyprice_withDiscount = 175, meanbuyprice_withDiscount = 175
        , lastbuyprice_withTax = 175, meanbuyprice_withTax = 175, lastbuyprice_withDiscountAndTax = 175
                where buybilldetailid = 32828;
UPDATE productunit SET proUnitBuyPrice  = 175 * productnumber WHERE productid = 16546;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16545';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16546', '1', '30', '0', '14185', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '30', '77', '2024-12-20 19:05:20','0','0');
UPDATE supplier SET  suppliercurrentDebt = '150185',suppliercurrentDebtInCurrency= '150185' , userid = '77', supplierdate = '2024-12-20 19:06:39'   WHERE supplierid = '101';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('101', '142610.00', '7575', '0', 'اضافة فاتورة مشتريات', '14185', '150185', '2024-12-20 19:05:20', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','7575','1','142610','7575','150185','0');
update buybill set dailyentryid='0,' where buybillid=14185;
COMMIT;
UPDATE product SET overAllAveragePrice = 155 WHERE productId = 16545;UPDATE product SET overAllAveragePrice = 175 WHERE productId = 16546;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:36:40";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:06:40", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:06:40', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14185');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:38:18";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:08:18", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 19:08:18', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:39:09";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:09:09", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:09:09', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:39:20";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:09:20", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:09:20', '77', 'details', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=details&id=14176');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:39:27";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:09:27", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:09:27', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE productunit SET unitid = '1', productid = '16378', productnumber = '1.00', productunitdate = '2024-12-10', userid = '77', conditions = '0',proUnitParcode='1637801',proUnitSellAllPrice='220',proUnitSellHalfPrice='220',proUnitSellUnitPrice ='220',proUnitBuyPrice='160',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16378';
UPDATE product SET productName = '7269', productDescription = '', productCatId = '5', productBuyPrice = '165', productSellAllPrice = '220', productSellUnitPrice = '220', productSellHalfPrice = '220', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07269',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '160.00',lastbuyprice_withDiscount = '160',meanbuyprice = '162.5',meanbuyprice_withDiscount = '162.5' , productbuypricereal = '160' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='160',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='160',meanbuyprice_withTax='160',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='160'  WHERE productId = '16378';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7348','','5','225','285', '285','285', '2024-12-20', '0', '77', '1', '07348', '0', '0', '0', '0', '0', '225','225','225','225','225','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','225','225','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16547, 1,'2024-12-20 19:10:02',77)
                ON DUPLICATE KEY UPDATE productid = 16547, edited = 1, sysdate = '2024-12-20 19:10:02', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16547', '1', '2024-12-20', '77', '0','1654701','285','285','285','225','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16547', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16547', '1', '0', '0', '16547', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:40:10";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:10:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:10:10', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a4c7ceb3e', '2024-12-20 19:09:27', '78', '322725.00', '328575', '0', '0', '5850',  '5850', '0', '5850', '1', '2024-12-20 19:10:10', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07269', '14186', '5', '16378', '15', '165', '2475', '0', '', '2024-12-20 19:10:10', '16378','','','0','0','0','0','0',null,'165','2475','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:09:27', 1, 16378, 0, 0
                    , 165, 15, 0, 0, 77, '2024-12-20 19:10:10')
                ON DUPLICATE KEY UPDATE buyprice = 165,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:10:10' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16378', '165', '15', '0', 'buyBillController.php', '32829', '', '0', '0');
UPDATE product SET  productBuyPrice = "165" WHERE productId = 16378 ;
UPDATE buybilldetail SET  quantitybefore = 21 WHERE buybilldetailid = 32829 ;
UPDATE product SET productName = '7269', productDescription = '', productCatId = '5', productBuyPrice = '165.00', productSellAllPrice = '220.00', productSellUnitPrice = '220.00', productSellHalfPrice = '220.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07269',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '165',lastbuyprice_withDiscount = '165',meanbuyprice = '164',meanbuyprice_withDiscount = '164' , productbuypricereal = '160.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='160',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='165',meanbuyprice_withTax='162',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='165'  WHERE productId = '16378';
UPDATE buybilldetail SET  lastbuyprice = 165 , meanbuyprice = 164, lastbuyprice_withDiscount = 165, meanbuyprice_withDiscount = 164
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 162, lastbuyprice_withDiscountAndTax = 165
                where buybilldetailid = 32829;
UPDATE productunit SET proUnitBuyPrice  = 165 * productnumber WHERE productid = 16378;
UPDATE storedetail SET  productquantity = '36', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16377';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16378', '1', '15', '0', '14186', 'اضافة فاتورة مشتريات', 'buyBillController.php', '21', '36', '77', '2024-12-20 19:09:27','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07348', '14186', '5', '16547', '15', '225', '3375', '0', '', '2024-12-20 19:10:10', '16547','','','0','0','0','0','0',null,'225','3375','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:09:27', 1, 16547, 0, 0
                    , 225, 15, 0, 0, 77, '2024-12-20 19:10:10')
                ON DUPLICATE KEY UPDATE buyprice = 225,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:10:10' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16547', '225', '15', '0', 'buyBillController.php', '32830', '', '0', '0');
UPDATE product SET  productBuyPrice = "225" WHERE productId = 16547 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32830 ;
UPDATE product SET productName = '7348', productDescription = '', productCatId = '5', productBuyPrice = '225.00', productSellAllPrice = '285.00', productSellUnitPrice = '285.00', productSellHalfPrice = '285.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07348',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '225',lastbuyprice_withDiscount = '225',meanbuyprice = '225',meanbuyprice_withDiscount = '225' , productbuypricereal = '225.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='225',meanbuyprice_withTax='225',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='225'  WHERE productId = '16547';
UPDATE buybilldetail SET  lastbuyprice = 225 , meanbuyprice = 225, lastbuyprice_withDiscount = 225, meanbuyprice_withDiscount = 225
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 225, lastbuyprice_withDiscountAndTax = 225
                where buybilldetailid = 32830;
UPDATE productunit SET proUnitBuyPrice  = 225 * productnumber WHERE productid = 16547;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16546';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16547', '1', '15', '0', '14186', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:09:27','0','0');
UPDATE supplier SET  suppliercurrentDebt = '328575',suppliercurrentDebtInCurrency= '328575' , userid = '77', supplierdate = '2024-12-20 19:10:10'   WHERE supplierid = '78';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('78', '322725.00', '5850', '0', 'اضافة فاتورة مشتريات', '14186', '328575', '2024-12-20 19:09:27', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','5850','1','322725','5850','328575','0');
update buybill set dailyentryid='0,' where buybillid=14186;
COMMIT;
UPDATE product SET overAllAveragePrice = 161.67 WHERE productId = 16378;UPDATE product SET overAllAveragePrice = 225 WHERE productId = 16547;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:40:11";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:10:11", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:10:11', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14186');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:41:43";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:11:43", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:11:44', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:42:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:12:27", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 19:12:27', '9', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=add');
BEGIN;
CALL supplierInUse(167,@supplierdebt,@suppliername,@dailyentryid,@treeIdis);
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('167', '6575.00', '10000', '1', 'ايصال دفع لمورد', '1', '-3425', '2024-12-20 19:08:18', '9', 'supplierPayedDeptController.php', '', '0','1', '-1','1','1','10000','1','0','0','0','412');
UPDATE supplierdebtchange SET supplierid = '167', supplierdebtchangebefore = '6575.00', supplierdebtchangeamount = '10000', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '-3425', supplierdebtchangedate = '2024-12-20 19:08:18', userid = '9', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='10000',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='6575',debtchangamountInSupplierCurrency='-3425',debtchangafterInSupplierCurrency='-3425', paySerialNo='412' WHERE supplierdebtchangeid = '26874';
UPDATE supplier SET  suppliercurrentDebt = '-3425',suppliercurrentDebtInCurrency= '-3425' , userid = '9', supplierdate = '2024-12-20 19:12:27'   WHERE supplierid = '167';
UPDATE supplier SET  inUse = 0 where supplierid = 167;
UPDATE save SET  savecurrentvalue = '795',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('10795.00','10000', '1', '1', 'ايصال دفع لمورد', '26874', '795', '2024-12-20 19:12:27', '9',  'supplierPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '10000', '10000', '2024-12-20', '9', '0', '0', '2024-12-20 19:12:27','ايصال دفع لمورد ( مصنع برافو ) ','1','0','0','0','26874','supplierReportsController.php?do=show&id=26874');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122351', '-1', '10000', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '10000', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122351', '-1', '10000', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-10000', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE supplierdebtchange SET supplierid = '167', supplierdebtchangebefore = '6575.00', supplierdebtchangeamount = '10000.00', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '-3425.00', supplierdebtchangedate = '2024-12-20 19:08:18', userid = '9', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '122351',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='10000',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='6575',debtchangamountInSupplierCurrency='-3425',debtchangafterInSupplierCurrency='-3425', paySerialNo='412' WHERE supplierdebtchangeid = '26874';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:42:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:12:28", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 19:12:28', '9', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:42:29";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:12:29", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-20 19:12:29', '9', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:42:30";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:12:30", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 19:12:30', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:42:35";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:12:35", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:12:35', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a5502d18b', '2024-12-20 19:11:44', '78', '328575.00', '335400', '0', '0', '6825',  '6825', '0', '6825', '1', '2024-12-20 19:12:35', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07323', '14187', '5', '16490', '15', '240', '3600', '0', '', '2024-12-20 19:12:35', '16490','','','0','0','0','0','0',null,'240','3600','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:11:44', 1, 16490, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-20 19:12:35')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:12:35' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16490', '240', '15', '0', 'buyBillController.php', '32831', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 16490 ;
UPDATE buybilldetail SET  quantitybefore = 15 WHERE buybilldetailid = 32831 ;
UPDATE product SET productName = '7323', productDescription = '', productCatId = '5', productBuyPrice = '240.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07323',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '240',lastbuyprice_withDiscount = '240',meanbuyprice = '240',meanbuyprice_withDiscount = '240' , productbuypricereal = '240.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='240',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='240',meanbuyprice_withTax='240',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='240'  WHERE productId = '16490';
UPDATE buybilldetail SET  lastbuyprice = 240 , meanbuyprice = 240, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 240
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32831;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16490;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16489';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16490', '1', '15', '0', '14187', 'اضافة فاتورة مشتريات', 'buyBillController.php', '15', '30', '77', '2024-12-20 19:11:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07265', '14187', '5', '16375', '15', '215', '3225', '0', '', '2024-12-20 19:12:35', '16375','','','0','0','0','0','0',null,'215','3225','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:11:44', 1, 16375, 0, 0
                    , 215, 15, 0, 0, 77, '2024-12-20 19:12:35')
                ON DUPLICATE KEY UPDATE buyprice = 215,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:12:35' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16375', '215', '15', '0', 'buyBillController.php', '32832', '', '0', '0');
UPDATE product SET  productBuyPrice = "215" WHERE productId = 16375 ;
UPDATE buybilldetail SET  quantitybefore = 7 WHERE buybilldetailid = 32832 ;
UPDATE product SET productName = '7265', productDescription = '', productCatId = '5', productBuyPrice = '215.00', productSellAllPrice = '265.00', productSellUnitPrice = '265.00', productSellHalfPrice = '265.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07265',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '215',lastbuyprice_withDiscount = '215',meanbuyprice = '215',meanbuyprice_withDiscount = '215' , productbuypricereal = '215.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='215',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='215',meanbuyprice_withTax='215',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='215'  WHERE productId = '16375';
UPDATE buybilldetail SET  lastbuyprice = 215 , meanbuyprice = 215, lastbuyprice_withDiscount = 215, meanbuyprice_withDiscount = 215
        , lastbuyprice_withTax = 215, meanbuyprice_withTax = 215, lastbuyprice_withDiscountAndTax = 215
                where buybilldetailid = 32832;
UPDATE productunit SET proUnitBuyPrice  = 215 * productnumber WHERE productid = 16375;
UPDATE storedetail SET  productquantity = '22', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16374';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16375', '1', '15', '0', '14187', 'اضافة فاتورة مشتريات', 'buyBillController.php', '7', '22', '77', '2024-12-20 19:11:44','0','0');
UPDATE supplier SET  suppliercurrentDebt = '335400',suppliercurrentDebtInCurrency= '335400' , userid = '77', supplierdate = '2024-12-20 19:12:35'   WHERE supplierid = '78';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('78', '328575.00', '6825', '0', 'اضافة فاتورة مشتريات', '14187', '335400', '2024-12-20 19:11:44', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','6825','1','328575','6825','335400','0');
update buybill set dailyentryid='0,' where buybillid=14187;
COMMIT;
UPDATE product SET overAllAveragePrice = 215 WHERE productId = 16375;UPDATE product SET overAllAveragePrice = 240 WHERE productId = 16490;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:42:36";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:12:36", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:12:36', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14187');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:42:48";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:12:48", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-20 19:12:48', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:42:50";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:12:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierController.php', '2024-12-20 19:12:50', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:42:55";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:12:55", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:12:55', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:42:56";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:12:56", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:12:56', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:44:15";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:14:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:14:15', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:45:37";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:15:37", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:15:37', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:45:37";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:15:37", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:15:37', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765a5e827c82
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 19:14:16', '06765a5e827c82', '1', '0.00', '0', '0', '1', '520.00', '520', '520', '0', '1', '2024-12-20 19:15:37', '', '9', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','520','0','','0','0','520','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150482', '0', '2024-12-20 19:15:37', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '520', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 19:14:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36023;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('450','H1638', '150482', '14', '16339', '1', '520', '520', '0', '', '1', '2024-12-20 19:15:38', '16339', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36023-1,','1','1','0','0','520','520','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
        , lastbuyprice_withTax = 450, meanbuyprice_withTax = 450, lastbuyprice_withDiscountAndTax = 450
                where sellbilldetailid = 549853;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16339, '2024-12-20', 520, 450, 450
                    , 450, 450, 450, 450
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 450, 450, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+450
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+450
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 520, 450, 450
                    , 450, 450, 450, 450
                    , 0, 0, 0, 0
                    , 0, 0, 0, 450, 450, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+450
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+450
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '9', storedetaildate = '2024-12-20 19:15:38' WHERE storedetailid = '16338';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16339', '1', '1', '1', '150482', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '9', '2024-12-20 19:15:38','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '1315',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('795','520', '0', '1', 'اضافة فاتورة مبيعات', '150482', '1315', '2024-12-20 19:15:38', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 520, 450, 450
                    , 450, 450, 450, 450
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,450, 450, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+450
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+450
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 520, 450, 450
                    , 450, 450, 450, 450
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,450, 450, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+450
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+450
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 520, 450, 450
                    , 450, 450, 450, 450, 450, 450)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+520, netSellCostBuyPrice = netSellCostBuyPrice+450
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+450
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+450
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+450
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+450
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+450
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+450
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+450;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765a5e827c82 and sellbillId = 150482 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:45:38";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:15:38", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:15:38', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:46:00";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:16:00", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:16:00', '77', 'editbill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editbill&id=14128');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:46:47";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:16:47", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:16:47', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067659a14ccb07
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:23:48', '067659a14ccb07', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2024-12-20 19:16:48', '', '9', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150483', '0', '2024-12-20 19:16:48', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 18:23:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32999;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('190','06517', '150483', '5', '14897', '1', '200', '200', '0', '', '1', '2024-12-20 19:16:48', '14897', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32999-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        
                where sellbilldetailid = 549854;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14897, '2024-12-20', 200, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '9', storedetaildate = '2024-12-20 19:16:48' WHERE storedetailid = '14896';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14897', '1', '1', '1', '150483', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '9', '2024-12-20 19:16:48','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '1515',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('1315','200', '0', '1', 'اضافة فاتورة مبيعات', '150483', '1515', '2024-12-20 19:16:48', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 3 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 200, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 200, 190, 190
                    , 190, 190, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+190
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+190
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+190
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+190
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+190
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067659a14ccb07 and sellbillId = 150483 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:46:48";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:16:48", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:16:48', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:47:17";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:17:17", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:17:17', '77', 'update', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=update');
BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 3) and  modelid = 14128;
UPDATE buybill SET  buybillsysdate = '2024-12-20 19:17:17', userid = '77',delbyuserid = '77', conditions = '1' WHERE buybillid = '14128';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-14 20:32:04', 1, 16466, 0, 0
                    , 290, 12, 0, 0, 77, '2024-12-20 19:17:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-12, sellQuantity = sellQuantity-0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:17:17' ;
UPDATE buybilldetail SET  lastbuyprice = 290.00 , meanbuyprice = 290.00, lastbuyprice_withDiscount = 290.00, meanbuyprice_withDiscount = 290.00
        , lastbuyprice_withTax = 290.00, meanbuyprice_withTax = 290.00, lastbuyprice_withDiscountAndTax = 290.00
                where buybilldetailid = 32687;
UPDATE product SET productName = '7317', productDescription = '', productCatId = '5', productBuyPrice = '290.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = '07317',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '290',lastbuyprice_withDiscount = '0',meanbuyprice = '290.00',meanbuyprice_withDiscount = '290' , productbuypricereal = '290.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='290',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='290',meanbuyprice_withTax='0',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='0'  WHERE productId = '16466';
UPDATE productunit SET proUnitBuyPrice  = 290 * productnumber WHERE productid = 16466;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16465';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16466', '1', '12', '1', '14128', 'حذف فاتورة مشتريات - للتعديل', 'buyBillController.php', '12', '0', '77', '2024-12-14 20:32:04','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-14 20:32:04', 1, 16467, 0, 0
                    , 290, 12, 0, 0, 77, '2024-12-20 19:17:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-12, sellQuantity = sellQuantity-0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:17:17' ;
UPDATE buybilldetail SET  lastbuyprice = 290.00 , meanbuyprice = 290.00, lastbuyprice_withDiscount = 290.00, meanbuyprice_withDiscount = 290.00
        , lastbuyprice_withTax = 290.00, meanbuyprice_withTax = 290.00, lastbuyprice_withDiscountAndTax = 290.00
                where buybilldetailid = 32688;
UPDATE product SET productName = '7312', productDescription = '', productCatId = '5', productBuyPrice = '290.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = '07312',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '290',lastbuyprice_withDiscount = '0',meanbuyprice = '290.00',meanbuyprice_withDiscount = '290' , productbuypricereal = '290.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='290',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='290',meanbuyprice_withTax='0',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='0'  WHERE productId = '16467';
UPDATE productunit SET proUnitBuyPrice  = 290 * productnumber WHERE productid = 16467;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16466';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16467', '1', '12', '1', '14128', 'حذف فاتورة مشتريات - للتعديل', 'buyBillController.php', '12', '0', '77', '2024-12-14 20:32:04','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-14 20:32:04', 1, 13529, 0, 0
                    , 280, 12, 0, 0, 77, '2024-12-20 19:17:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-12, sellQuantity = sellQuantity-0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:17:17' ;
UPDATE product SET productName = '6065', productDescription = '', productCatId = '5', productBuyPrice = '280.00', productSellAllPrice = '330.00', productSellUnitPrice = '330.00', productSellHalfPrice = '330.00', productDate = '2024-07-18', conditions = '0', userId = '77', limitamount = '1', parcode = '06065',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '270',lastbuyprice_withDiscount = '270',meanbuyprice = '277',meanbuyprice_withDiscount = '277' , productbuypricereal = '270.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='271.67',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='270',meanbuyprice_withTax='93',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='0'  WHERE productId = '13529';
UPDATE productunit SET proUnitBuyPrice  = 270 * productnumber WHERE productid = 13529;
UPDATE storedetail SET  productquantity = '-9', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '13528';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13529', '1', '12', '1', '14128', 'حذف فاتورة مشتريات - للتعديل', 'buyBillController.php', '3', '-9', '77', '2024-12-14 20:32:04','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-14 20:32:04', 1, 16468, 0, 0
                    , 280, 12, 0, 0, 77, '2024-12-20 19:17:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-12, sellQuantity = sellQuantity-0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:17:17' ;
UPDATE buybilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        , lastbuyprice_withTax = 280.00, meanbuyprice_withTax = 280.00, lastbuyprice_withDiscountAndTax = 280.00
                where buybilldetailid = 32690;
UPDATE product SET productName = '7310', productDescription = '', productCatId = '5', productBuyPrice = '280.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = '07310',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '280',lastbuyprice_withDiscount = '0',meanbuyprice = '280',meanbuyprice_withDiscount = '280' , productbuypricereal = '280.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='280',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='280',meanbuyprice_withTax='280',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='0'  WHERE productId = '16468';
UPDATE productunit SET proUnitBuyPrice  = 280 * productnumber WHERE productid = 16468;
UPDATE storedetail SET  productquantity = '-2', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16467';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16468', '1', '12', '1', '14128', 'حذف فاتورة مشتريات - للتعديل', 'buyBillController.php', '10', '-2', '77', '2024-12-14 20:32:04','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-14 20:32:04', 1, 16469, 0, 0
                    , 290, 12, 0, 0, 77, '2024-12-20 19:17:18')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-12, sellQuantity = sellQuantity-0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:17:18' ;
UPDATE buybilldetail SET  lastbuyprice = 290.00 , meanbuyprice = 290.00, lastbuyprice_withDiscount = 290.00, meanbuyprice_withDiscount = 290.00
        , lastbuyprice_withTax = 290.00, meanbuyprice_withTax = 290.00, lastbuyprice_withDiscountAndTax = 290.00
                where buybilldetailid = 32691;
UPDATE product SET productName = '7315', productDescription = '', productCatId = '5', productBuyPrice = '290.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = '07315',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '290',lastbuyprice_withDiscount = '0',meanbuyprice = '290.00',meanbuyprice_withDiscount = '290' , productbuypricereal = '290.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='290',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='290',meanbuyprice_withTax='0',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='0'  WHERE productId = '16469';
UPDATE productunit SET proUnitBuyPrice  = 290 * productnumber WHERE productid = 16469;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16468';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16469', '1', '12', '1', '14128', 'حذف فاتورة مشتريات - للتعديل', 'buyBillController.php', '12', '0', '77', '2024-12-14 20:32:04','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-14 20:32:04', 1, 16275, 0, 0
                    , 280, 12, 0, 0, 77, '2024-12-20 19:17:18')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-12, sellQuantity = sellQuantity-0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:17:18' ;
UPDATE product SET productName = '7195', productDescription = '', productCatId = '5', productBuyPrice = '280.00', productSellAllPrice = '330.00', productSellUnitPrice = '330.00', productSellHalfPrice = '330.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '0', parcode = '07195',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '280',lastbuyprice_withDiscount = '280',meanbuyprice = '281',meanbuyprice_withDiscount = '281' , productbuypricereal = '330.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='280',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',barcodeInTax='',productNameE='',partNumber='0',vehicleType='-1',company='-1',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='280',meanbuyprice_withTax='281',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='0'  WHERE productId = '16275';
UPDATE productunit SET proUnitBuyPrice  = 280 * productnumber WHERE productid = 16275;
UPDATE storedetail SET  productquantity = '26', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16274';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16275', '1', '12', '1', '14128', 'حذف فاتورة مشتريات - للتعديل', 'buyBillController.php', '38', '26', '77', '2024-12-14 20:32:04','0','0');
UPDATE supplier SET  suppliercurrentDebt = '239710',suppliercurrentDebtInCurrency= '239710' , userid = '77', supplierdate = '2024-12-20 19:17:17'   WHERE supplierid = '19';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('19', '260230.00', '20520.00', '1', 'حذف فاتورة مشتريات - للتعديل', '14128', '239710', '2024-12-14 20:32:04', '77', 'buyBillController.php', 'حذف فاتورة مشتريات - للتعديل', '0','', '0','1','1','20520','1','260230','20520','239710','0');
UPDATE productserial SET del = 1
		 WHERE billid = 14128;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,deletedbuyid,controlname,payedtax,costcenterid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('0675dcf24a6ffd', '2024-12-14 20:41:29', '19', '239710.00', '262470', '0', '0', '22760', '22760', '0.00', '22760', '1', '2024-12-20 19:17:17', '', '77', '0', '', '1', '1','1','14128','buyBillController.php','0.00','-1','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07317', '14188', '5', '16466', '12.00', '290', '3480', '0.00', '', '2024-12-20 19:17:17', '16466','','','0','0','0','0','0',null,'290','3480','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-14 20:41:29', 1, 16466, 0, 0
                    , 290, 12, 0, 0, 77, '2024-12-20 19:17:18')
                ON DUPLICATE KEY UPDATE buyprice = 290,
                        buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:17:18' ;
UPDATE product SET  productBuyPrice = "290" WHERE productId = 16466 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32833 ;
UPDATE product SET productName = '7317', productDescription = '', productCatId = '5', productBuyPrice = '290.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = '07317',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '290',lastbuyprice_withDiscount = '290',meanbuyprice = '290',meanbuyprice_withDiscount = '290' , productbuypricereal = '290.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='290',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='290',meanbuyprice_withTax='145',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='290'  WHERE productId = '16466';
UPDATE buybilldetail SET  lastbuyprice = 290 , meanbuyprice = 290, lastbuyprice_withDiscount = 290, meanbuyprice_withDiscount = 290
        , lastbuyprice_withTax = 290, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 290
                where buybilldetailid = 32833;
UPDATE productunit SET proUnitBuyPrice  = 290 * productnumber WHERE productid = 16466;
UPDATE storedetail SET  productquantity = '12', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16465';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16466', '1', '12', '0', '14188', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '12', '77', '2024-12-14 20:41:29','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07312', '14188', '5', '16467', '12.00', '290', '3480', '0.00', '', '2024-12-20 19:17:17', '16467','','','0','0','0','0','0',null,'290','3480','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-14 20:41:29', 1, 16467, 0, 0
                    , 290, 12, 0, 0, 77, '2024-12-20 19:17:18')
                ON DUPLICATE KEY UPDATE buyprice = 290,
                        buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:17:18' ;
UPDATE product SET  productBuyPrice = "290" WHERE productId = 16467 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32834 ;
UPDATE product SET productName = '7312', productDescription = '', productCatId = '5', productBuyPrice = '290.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = '07312',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '290',lastbuyprice_withDiscount = '290',meanbuyprice = '290',meanbuyprice_withDiscount = '290' , productbuypricereal = '290.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='290',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='290',meanbuyprice_withTax='145',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='290'  WHERE productId = '16467';
UPDATE buybilldetail SET  lastbuyprice = 290 , meanbuyprice = 290, lastbuyprice_withDiscount = 290, meanbuyprice_withDiscount = 290
        , lastbuyprice_withTax = 290, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 290
                where buybilldetailid = 32834;
UPDATE productunit SET proUnitBuyPrice  = 290 * productnumber WHERE productid = 16467;
UPDATE storedetail SET  productquantity = '12', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16466';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16467', '1', '12', '0', '14188', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '12', '77', '2024-12-14 20:41:29','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06065', '14188', '5', '13529', '12.00', '280', '3360', '0.00', '', '2024-12-20 19:17:17', '13529','','','0','0','0','0','0',null,'280','3360','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-14 20:41:29', 1, 13529, 0, 0
                    , 280, 12, 0, 0, 77, '2024-12-20 19:17:18')
                ON DUPLICATE KEY UPDATE buyprice = 280,
                        buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:17:18' ;
UPDATE product SET  productBuyPrice = "280" WHERE productId = 13529 ;
UPDATE buybilldetail SET  quantitybefore = -9 WHERE buybilldetailid = 32835 ;
UPDATE product SET productName = '6065', productDescription = '', productCatId = '5', productBuyPrice = '280.00', productSellAllPrice = '330.00', productSellUnitPrice = '330.00', productSellHalfPrice = '330.00', productDate = '2024-07-18', conditions = '0', userId = '77', limitamount = '1', parcode = '06065',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '280',lastbuyprice_withDiscount = '280',meanbuyprice = '279',meanbuyprice_withDiscount = '279' , productbuypricereal = '270.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='271.67',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='280',meanbuyprice_withTax='243',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='280'  WHERE productId = '13529';
UPDATE buybilldetail SET  lastbuyprice = 280 , meanbuyprice = 279, lastbuyprice_withDiscount = 280, meanbuyprice_withDiscount = 279
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 243, lastbuyprice_withDiscountAndTax = 280
                where buybilldetailid = 32835;
UPDATE productunit SET proUnitBuyPrice  = 280 * productnumber WHERE productid = 13529;
UPDATE storedetail SET  productquantity = '3', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '13528';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13529', '1', '12', '0', '14188', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-9', '3', '77', '2024-12-14 20:41:29','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07310', '14188', '5', '16468', '12.00', '280', '3360', '0.00', '', '2024-12-20 19:17:17', '16468','','','0','0','0','0','0',null,'280','3360','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-14 20:41:29', 1, 16468, 0, 0
                    , 280, 12, 0, 0, 77, '2024-12-20 19:17:18')
                ON DUPLICATE KEY UPDATE buyprice = 280,
                        buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:17:18' ;
UPDATE product SET  productBuyPrice = "280" WHERE productId = 16468 ;
UPDATE buybilldetail SET  quantitybefore = -2 WHERE buybilldetailid = 32836 ;
UPDATE product SET productName = '7310', productDescription = '', productCatId = '5', productBuyPrice = '280.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = '07310',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '280',lastbuyprice_withDiscount = '280',meanbuyprice = '280',meanbuyprice_withDiscount = '280' , productbuypricereal = '280.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='280',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='280',meanbuyprice_withTax='280',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='280'  WHERE productId = '16468';
UPDATE buybilldetail SET  lastbuyprice = 280 , meanbuyprice = 280, lastbuyprice_withDiscount = 280, meanbuyprice_withDiscount = 280
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 280, lastbuyprice_withDiscountAndTax = 280
                where buybilldetailid = 32836;
UPDATE productunit SET proUnitBuyPrice  = 280 * productnumber WHERE productid = 16468;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16467';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16468', '1', '12', '0', '14188', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-2', '10', '77', '2024-12-14 20:41:29','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07315', '14188', '5', '16469', '12.00', '290', '3480', '0.00', '', '2024-12-20 19:17:17', '16469','','','0','0','0','0','0',null,'290','3480','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-14 20:41:29', 1, 16469, 0, 0
                    , 290, 12, 0, 0, 77, '2024-12-20 19:17:18')
                ON DUPLICATE KEY UPDATE buyprice = 290,
                        buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:17:18' ;
UPDATE product SET  productBuyPrice = "290" WHERE productId = 16469 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32837 ;
UPDATE product SET productName = '7315', productDescription = '', productCatId = '5', productBuyPrice = '290.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = '07315',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '290',lastbuyprice_withDiscount = '290',meanbuyprice = '290',meanbuyprice_withDiscount = '290' , productbuypricereal = '290.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='290',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='290',meanbuyprice_withTax='145',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='290'  WHERE productId = '16469';
UPDATE buybilldetail SET  lastbuyprice = 290 , meanbuyprice = 290, lastbuyprice_withDiscount = 290, meanbuyprice_withDiscount = 290
        , lastbuyprice_withTax = 290, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 290
                where buybilldetailid = 32837;
UPDATE productunit SET proUnitBuyPrice  = 290 * productnumber WHERE productid = 16469;
UPDATE storedetail SET  productquantity = '12', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16468';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16469', '1', '12', '0', '14188', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '12', '77', '2024-12-14 20:41:29','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07195', '14188', '5', '16275', '20', '280', '5600', '0.00', '', '2024-12-20 19:17:17', '16275','','','0','0','0','0','0',null,'280','5600','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-14 20:41:29', 1, 16275, 0, 0
                    , 280, 20, 0, 0, 77, '2024-12-20 19:17:18')
                ON DUPLICATE KEY UPDATE buyprice = 280,
                        buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:17:18' ;
UPDATE product SET  productBuyPrice = "280" WHERE productId = 16275 ;
UPDATE buybilldetail SET  quantitybefore = 26 WHERE buybilldetailid = 32838 ;
UPDATE product SET productName = '7195', productDescription = '', productCatId = '5', productBuyPrice = '280.00', productSellAllPrice = '330.00', productSellUnitPrice = '330.00', productSellHalfPrice = '330.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '0', parcode = '07195',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '280',lastbuyprice_withDiscount = '280',meanbuyprice = '281',meanbuyprice_withDiscount = '281' , productbuypricereal = '330.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='280',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',barcodeInTax='',productNameE='',partNumber='0',vehicleType='-1',company='-1',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='280',meanbuyprice_withTax='281',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='280'  WHERE productId = '16275';
UPDATE buybilldetail SET  lastbuyprice = 280 , meanbuyprice = 281, lastbuyprice_withDiscount = 280, meanbuyprice_withDiscount = 281
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 281, lastbuyprice_withDiscountAndTax = 280
                where buybilldetailid = 32838;
UPDATE productunit SET proUnitBuyPrice  = 280 * productnumber WHERE productid = 16275;
UPDATE storedetail SET  productquantity = '46', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16274';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16275', '1', '20', '0', '14188', 'اضافة فاتورة مشتريات', 'buyBillController.php', '26', '46', '77', '2024-12-14 20:41:29','0','0');
DELETE FROM productserial WHERE billid = 14128
		and type =0 
		;
UPDATE supplier SET  suppliercurrentDebt = '262470',suppliercurrentDebtInCurrency= '262470' , userid = '77', supplierdate = '2024-12-20 19:17:17'   WHERE supplierid = '19';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('19', '239710.00', '22760', '0', 'اضافة فاتورة مشتريات', '14188', '262470', '2024-12-20 19:17:17', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','20520','1','239710','22760','262470','0');
update buybill set dailyentryid='0,' where buybillid=14188;
UPDATE product SET overAllAveragePrice = 271.67 WHERE productId = 13529;UPDATE product SET overAllAveragePrice = 280 WHERE productId = 16275;UPDATE product SET overAllAveragePrice = 290 WHERE productId = 16466;UPDATE product SET overAllAveragePrice = 290 WHERE productId = 16467;UPDATE product SET overAllAveragePrice = 280 WHERE productId = 16468;UPDATE product SET overAllAveragePrice = 290 WHERE productId = 16469;;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:47:18";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:17:18", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:17:18', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14188');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:47:31";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:17:31", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 19:17:31', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE userid = 101;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:48:28";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:18:28", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:18:28', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7338','','5','220','280', '280','280', '2024-12-20', '0', '77', '1', '07338', '0', '0', '0', '0', '0', '220','220','220','220','220','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','220','220','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16548, 1,'2024-12-20 19:18:51',77)
                ON DUPLICATE KEY UPDATE productid = 16548, edited = 1, sysdate = '2024-12-20 19:18:51', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16548', '1', '2024-12-20', '77', '0','1654801','280','280','280','220','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16548', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16548', '1', '0', '0', '16548', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7341','','5','210','260', '260','260', '2024-12-20', '0', '77', '1', '07341', '0', '0', '0', '0', '0', '210','210','210','210','210','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','210','210','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16549, 1,'2024-12-20 19:19:15',77)
                ON DUPLICATE KEY UPDATE productid = 16549, edited = 1, sysdate = '2024-12-20 19:19:15', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16549', '1', '2024-12-20', '77', '0','1654901','260','260','260','210','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16549', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16549', '1', '0', '0', '16549', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:49:23";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 19:19:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 19:19:23', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:49:24";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:49:32";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 19:19:32", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 19:19:32', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:50:45";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 19:20:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 19:20:45', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7342','','5','495','580', '580','580', '2024-12-20', '0', '77', '1', '07342', '0', '0', '0', '0', '0', '495','495','495','495','495','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','495','495','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16550, 1,'2024-12-20 19:20:49',77)
                ON DUPLICATE KEY UPDATE productid = 16550, edited = 1, sysdate = '2024-12-20 19:20:49', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16550', '1', '2024-12-20', '77', '0','1655001','580','580','580','495','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16550', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16550', '1', '0', '0', '16550', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:50:49";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 19:20:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 19:20:49', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:51:07";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:21:07", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:21:07', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a6e4ddefa', '2024-12-20 19:18:28', '19', '262470.00', '288945', '0', '0', '26475',  '26475', '0', '26475', '1', '2024-12-20 19:21:07', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07338', '14189', '5', '16548', '15', '220', '3300', '0', '', '2024-12-20 19:21:07', '16548','','','0','0','0','0','0',null,'220','3300','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:18:28', 1, 16548, 0, 0
                    , 220, 15, 0, 0, 77, '2024-12-20 19:21:07')
                ON DUPLICATE KEY UPDATE buyprice = 220,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:21:07' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16548', '220', '15', '0', 'buyBillController.php', '32839', '', '0', '0');
UPDATE product SET  productBuyPrice = "220" WHERE productId = 16548 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32839 ;
UPDATE product SET productName = '7338', productDescription = '', productCatId = '5', productBuyPrice = '220.00', productSellAllPrice = '280.00', productSellUnitPrice = '280.00', productSellHalfPrice = '280.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07338',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '220',lastbuyprice_withDiscount = '220',meanbuyprice = '220',meanbuyprice_withDiscount = '220' , productbuypricereal = '220.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='220',meanbuyprice_withTax='220',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='220'  WHERE productId = '16548';
UPDATE buybilldetail SET  lastbuyprice = 220 , meanbuyprice = 220, lastbuyprice_withDiscount = 220, meanbuyprice_withDiscount = 220
        , lastbuyprice_withTax = 220, meanbuyprice_withTax = 220, lastbuyprice_withDiscountAndTax = 220
                where buybilldetailid = 32839;
UPDATE productunit SET proUnitBuyPrice  = 220 * productnumber WHERE productid = 16548;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16547';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16548', '1', '15', '0', '14189', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:18:28','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07341', '14189', '5', '16549', '15', '210', '3150', '0', '', '2024-12-20 19:21:07', '16549','','','0','0','0','0','0',null,'210','3150','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:18:28', 1, 16549, 0, 0
                    , 210, 15, 0, 0, 77, '2024-12-20 19:21:07')
                ON DUPLICATE KEY UPDATE buyprice = 210,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:21:07' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16549', '210', '15', '0', 'buyBillController.php', '32840', '', '0', '0');
UPDATE product SET  productBuyPrice = "210" WHERE productId = 16549 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32840 ;
UPDATE product SET productName = '7341', productDescription = '', productCatId = '5', productBuyPrice = '210.00', productSellAllPrice = '260.00', productSellUnitPrice = '260.00', productSellHalfPrice = '260.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07341',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210',lastbuyprice_withDiscount = '210',meanbuyprice = '210',meanbuyprice_withDiscount = '210' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='210',meanbuyprice_withTax='210',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='210'  WHERE productId = '16549';
UPDATE buybilldetail SET  lastbuyprice = 210 , meanbuyprice = 210, lastbuyprice_withDiscount = 210, meanbuyprice_withDiscount = 210
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where buybilldetailid = 32840;
UPDATE productunit SET proUnitBuyPrice  = 210 * productnumber WHERE productid = 16549;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16548';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16549', '1', '15', '0', '14189', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:18:28','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06958', '14189', '5', '15855', '30', '145', '4350', '0', '', '2024-12-20 19:21:07', '15855','','','0','0','0','0','0',null,'145','4350','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:18:28', 1, 15855, 0, 0
                    , 145, 30, 0, 0, 77, '2024-12-20 19:21:08')
                ON DUPLICATE KEY UPDATE buyprice = 145,
                        buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:21:08' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15855', '145', '30', '0', 'buyBillController.php', '32841', '', '0', '0');
UPDATE product SET  productBuyPrice = "145" WHERE productId = 15855 ;
UPDATE buybilldetail SET  quantitybefore = 19 WHERE buybilldetailid = 32841 ;
UPDATE product SET productName = '6958', productDescription = '', productCatId = '5', productBuyPrice = '145.00', productSellAllPrice = '210.00', productSellUnitPrice = '210.00', productSellHalfPrice = '210.00', productDate = '2024-11-05', conditions = '0', userId = '77', limitamount = '1', parcode = '06958',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '145',lastbuyprice_withDiscount = '145',meanbuyprice = '145',meanbuyprice_withDiscount = '145' , productbuypricereal = '145.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='145',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='145',meanbuyprice_withTax='145',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='145'  WHERE productId = '15855';
UPDATE buybilldetail SET  lastbuyprice = 145 , meanbuyprice = 145, lastbuyprice_withDiscount = 145, meanbuyprice_withDiscount = 145
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where buybilldetailid = 32841;
UPDATE productunit SET proUnitBuyPrice  = 145 * productnumber WHERE productid = 15855;
UPDATE storedetail SET  productquantity = '49', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '15854';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15855', '1', '30', '0', '14189', 'اضافة فاتورة مشتريات', 'buyBillController.php', '19', '49', '77', '2024-12-20 19:18:28','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07318', '14189', '5', '16488', '15', '455', '6825', '0', '', '2024-12-20 19:21:07', '16488','','','0','0','0','0','0',null,'455','6825','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:18:28', 1, 16488, 0, 0
                    , 455, 15, 0, 0, 77, '2024-12-20 19:21:08')
                ON DUPLICATE KEY UPDATE buyprice = 455,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:21:08' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16488', '455', '15', '0', 'buyBillController.php', '32842', '', '0', '0');
UPDATE product SET  productBuyPrice = "455" WHERE productId = 16488 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32842 ;
UPDATE product SET productName = '7318', productDescription = '', productCatId = '5', productBuyPrice = '455.00', productSellAllPrice = '530.00', productSellUnitPrice = '530.00', productSellHalfPrice = '530.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07318',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '455',lastbuyprice_withDiscount = '455',meanbuyprice = '455',meanbuyprice_withDiscount = '455' , productbuypricereal = '455.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='455',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='455',meanbuyprice_withTax='455',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='455'  WHERE productId = '16488';
UPDATE buybilldetail SET  lastbuyprice = 455 , meanbuyprice = 455, lastbuyprice_withDiscount = 455, meanbuyprice_withDiscount = 455
        , lastbuyprice_withTax = 455, meanbuyprice_withTax = 455, lastbuyprice_withDiscountAndTax = 455
                where buybilldetailid = 32842;
UPDATE productunit SET proUnitBuyPrice  = 455 * productnumber WHERE productid = 16488;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16487';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16488', '1', '15', '0', '14189', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:18:28','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06903', '14189', '5', '15753', '15', '260', '3900', '0', '', '2024-12-20 19:21:07', '15753','','','0','0','0','0','0',null,'260','3900','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:18:28', 1, 15753, 0, 0
                    , 260, 15, 0, 0, 77, '2024-12-20 19:21:08')
                ON DUPLICATE KEY UPDATE buyprice = 260,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:21:08' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15753', '260', '15', '0', 'buyBillController.php', '32843', '', '0', '0');
UPDATE product SET  productBuyPrice = "260" WHERE productId = 15753 ;
UPDATE buybilldetail SET  quantitybefore = 15 WHERE buybilldetailid = 32843 ;
UPDATE product SET productName = '6903', productDescription = '', productCatId = '5', productBuyPrice = '260.00', productSellAllPrice = '320.00', productSellUnitPrice = '320.00', productSellHalfPrice = '320.00', productDate = '2024-10-29', conditions = '0', userId = '77', limitamount = '1', parcode = '06903',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='259.44',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='260',meanbuyprice_withTax='260',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='260'  WHERE productId = '15753';
UPDATE buybilldetail SET  lastbuyprice = 260 , meanbuyprice = 260, lastbuyprice_withDiscount = 260, meanbuyprice_withDiscount = 260
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 260, lastbuyprice_withDiscountAndTax = 260
                where buybilldetailid = 32843;
UPDATE productunit SET proUnitBuyPrice  = 260 * productnumber WHERE productid = 15753;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '15752';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15753', '1', '15', '0', '14189', 'اضافة فاتورة مشتريات', 'buyBillController.php', '15', '30', '77', '2024-12-20 19:18:28','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07342', '14189', '5', '16550', '10', '495', '4950', '0', '', '2024-12-20 19:21:07', '16550','','','0','0','0','0','0',null,'495','4950','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:18:28', 1, 16550, 0, 0
                    , 495, 10, 0, 0, 77, '2024-12-20 19:21:08')
                ON DUPLICATE KEY UPDATE buyprice = 495,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:21:08' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16550', '495', '10', '0', 'buyBillController.php', '32844', '', '0', '0');
UPDATE product SET  productBuyPrice = "495" WHERE productId = 16550 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32844 ;
UPDATE product SET productName = '7342', productDescription = '', productCatId = '5', productBuyPrice = '495.00', productSellAllPrice = '580.00', productSellUnitPrice = '580.00', productSellHalfPrice = '580.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07342',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '495',lastbuyprice_withDiscount = '495',meanbuyprice = '495',meanbuyprice_withDiscount = '495' , productbuypricereal = '495.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='495',meanbuyprice_withTax='495',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='495'  WHERE productId = '16550';
UPDATE buybilldetail SET  lastbuyprice = 495 , meanbuyprice = 495, lastbuyprice_withDiscount = 495, meanbuyprice_withDiscount = 495
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 495, lastbuyprice_withDiscountAndTax = 495
                where buybilldetailid = 32844;
UPDATE productunit SET proUnitBuyPrice  = 495 * productnumber WHERE productid = 16550;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16549';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16550', '1', '10', '0', '14189', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-20 19:18:28','0','0');
UPDATE supplier SET  suppliercurrentDebt = '288945',suppliercurrentDebtInCurrency= '288945' , userid = '77', supplierdate = '2024-12-20 19:21:07'   WHERE supplierid = '19';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('19', '262470.00', '26475', '0', 'اضافة فاتورة مشتريات', '14189', '288945', '2024-12-20 19:18:28', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','26475','1','262470','26475','288945','0');
update buybill set dailyentryid='0,' where buybillid=14189;
COMMIT;
UPDATE product SET overAllAveragePrice = 259.5 WHERE productId = 15753;UPDATE product SET overAllAveragePrice = 145 WHERE productId = 15855;UPDATE product SET overAllAveragePrice = 455 WHERE productId = 16488;UPDATE product SET overAllAveragePrice = 220 WHERE productId = 16548;UPDATE product SET overAllAveragePrice = 210 WHERE productId = 16549;UPDATE product SET overAllAveragePrice = 495 WHERE productId = 16550;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:51:08";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:21:08", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:21:08', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14189');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:51:32";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:21:32", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:21:32', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765a63abe8c1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 19:15:38', '06765a63abe8c1', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-20 19:21:32', '', '9', '0', 'نقدي', '1', '0', '3', '26', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','300','0','','0','0','300','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150484', '0', '2024-12-20 19:21:32', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 19:15:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34635;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('260','06717', '150484', '5', '15245', '1', '300', '300', '0', '', '1', '2024-12-20 19:21:32', '15245', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34635-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 270.00
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 225, lastbuyprice_withDiscountAndTax = 260
                where sellbilldetailid = 549855;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15245, '2024-12-20', 300, 260, 260
                    , 270, 260, 270, 259.29
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 260, 225, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+225
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 260, 260
                    , 270, 260, 270, 259.29
                    , 0, 0, 0, 0
                    , 0, 0, 0, 260, 225, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+225
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '27', userid = '9', storedetaildate = '2024-12-20 19:21:32' WHERE storedetailid = '15244';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15245', '1', '1', '1', '150484', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '27', '9', '2024-12-20 19:21:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '1815',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('1515','300', '0', '1', 'اضافة فاتورة مبيعات', '150484', '1815', '2024-12-20 19:21:32', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 26 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 300, 260, 260
                    , 270, 260, 270, 259.29
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,260, 225, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+225
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 260, 260
                    , 270, 260, 270, 259.29
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,260, 225, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+225
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 300, 260, 260
                    , 270, 260, 270, 259.29, 260, 225)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+260
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+260
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+270
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+260
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+270
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+259.29
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+260
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+225;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765a63abe8c1 and sellbillId = 150484 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:51:33";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:21:33", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:21:33', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:51:53";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:21:53", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 19:21:53', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:51:58";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:21:58", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:21:58', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:52:08";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:22:08", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:22:08', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:52:23";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:22:23", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:22:23', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a7c055d06', '2024-12-20 19:22:08', '19', '288945.00', '293895', '0', '0', '4950',  '4950', '0', '4950', '1', '2024-12-20 19:22:23', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07342', '14190', '5', '16550', '10', '495', '4950', '0', '', '2024-12-20 19:22:23', '16550','','','0','0','0','0','0',null,'495','4950','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:22:08', 1, 16550, 0, 0
                    , 495, 10, 0, 0, 77, '2024-12-20 19:22:23')
                ON DUPLICATE KEY UPDATE buyprice = 495,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:22:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16550', '495', '10', '0', 'buyBillController.php', '32845', '', '0', '0');
UPDATE product SET  productBuyPrice = "495" WHERE productId = 16550 ;
UPDATE buybilldetail SET  quantitybefore = 10 WHERE buybilldetailid = 32845 ;
UPDATE product SET productName = '7342', productDescription = '', productCatId = '5', productBuyPrice = '495.00', productSellAllPrice = '580.00', productSellUnitPrice = '580.00', productSellHalfPrice = '580.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07342',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '495',lastbuyprice_withDiscount = '495',meanbuyprice = '495',meanbuyprice_withDiscount = '495' , productbuypricereal = '495.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='495',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='495',meanbuyprice_withTax='495',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='495'  WHERE productId = '16550';
UPDATE buybilldetail SET  lastbuyprice = 495 , meanbuyprice = 495, lastbuyprice_withDiscount = 495, meanbuyprice_withDiscount = 495
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 495, lastbuyprice_withDiscountAndTax = 495
                where buybilldetailid = 32845;
UPDATE productunit SET proUnitBuyPrice  = 495 * productnumber WHERE productid = 16550;
UPDATE storedetail SET  productquantity = '20', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16549';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16550', '1', '10', '0', '14190', 'اضافة فاتورة مشتريات', 'buyBillController.php', '10', '20', '77', '2024-12-20 19:22:08','0','0');
UPDATE supplier SET  suppliercurrentDebt = '293895',suppliercurrentDebtInCurrency= '293895' , userid = '77', supplierdate = '2024-12-20 19:22:23'   WHERE supplierid = '19';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('19', '288945.00', '4950', '0', 'اضافة فاتورة مشتريات', '14190', '293895', '2024-12-20 19:22:08', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','4950','1','288945','4950','293895','0');
update buybill set dailyentryid='0,' where buybillid=14190;
COMMIT;
UPDATE product SET overAllAveragePrice = 495 WHERE productId = 16550;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:52:24";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:22:24", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:22:24', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14190');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:52:31";
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:52:32";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:52:44";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:22:44", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:22:44', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:52:49";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 19:22:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 19:22:49', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:52:49";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:52:53";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 19:22:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 19:22:53', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:52:53";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:22:53", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 19:22:53', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:53:00";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:23:00", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 19:23:00', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:53:10";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:23:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:23:10', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE productunit SET unitid = '1', productid = '16547', productnumber = '1.00', productunitdate = '2024-12-20', userid = '77', conditions = '0',proUnitParcode='1654701',proUnitSellAllPrice='285',proUnitSellHalfPrice='285',proUnitSellUnitPrice ='285',proUnitBuyPrice='225',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16547';
UPDATE product SET productName = '7348', productDescription = '', productCatId = '5', productBuyPrice = '220', productSellAllPrice = '285', productSellUnitPrice = '285', productSellHalfPrice = '285', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07348',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '222.5',meanbuyprice_withDiscount = '222.5' , productbuypricereal = '225' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='225',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='225',meanbuyprice_withTax='225',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='225'  WHERE productId = '16547';
UPDATE productunit SET unitid = '1', productid = '16375', productnumber = '1.00', productunitdate = '2024-12-10', userid = '77', conditions = '0',proUnitParcode='1637501',proUnitSellAllPrice='265',proUnitSellHalfPrice='265',proUnitSellUnitPrice ='265',proUnitBuyPrice='215',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16375';
UPDATE product SET productName = '7265', productDescription = '', productCatId = '5', productBuyPrice = '220', productSellAllPrice = '265', productSellUnitPrice = '265', productSellHalfPrice = '265', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07265',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '215.00',lastbuyprice_withDiscount = '215',meanbuyprice = '217.5',meanbuyprice_withDiscount = '217.5' , productbuypricereal = '215' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='215',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='215',meanbuyprice_withTax='215',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='215'  WHERE productId = '16375';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7367','','5','275','335', '335','335', '2024-12-20', '0', '77', '1', '07367', '0', '0', '0', '0', '0', '275','275','275','275','275','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','275','275','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16551, 1,'2024-12-20 19:24:14',77)
                ON DUPLICATE KEY UPDATE productid = 16551, edited = 1, sysdate = '2024-12-20 19:24:14', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16551', '1', '2024-12-20', '77', '0','1655101','335','335','335','275','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16551', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16551', '1', '0', '0', '16551', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:54:46";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 19:24:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 19:24:46', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:55:14";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 19:25:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 19:25:14', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:55:15";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:55:25";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 19:25:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 19:25:25', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:55:30";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:25:30", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:25:30', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765a7b71a490
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 19:21:59', '06765a7b71a490', '1', '0.00', '0', '0', '1', '600.00', '600', '600', '0', '1', '2024-12-20 19:25:30', '', '9', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','600','0','','0','0','600','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150485', '0', '2024-12-20 19:25:30', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '600', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 19:21:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36148;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('445','H1621', '150485', '14', '16255', '1', '600', '600', '0', '', '1', '2024-12-20 19:25:30', '16255', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36148-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 435.00 , meanbuyprice = 414.00, lastbuyprice_withDiscount = 435.00, meanbuyprice_withDiscount = 414.00
        , lastbuyprice_withTax = 435, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 435
                where sellbilldetailid = 549856;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16255, '2024-12-20', 600, 435, 435
                    , 414, 435, 414, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 435, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+435
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+435, sellCostMeanBuyPrice = sellCostMeanBuyPrice+414
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+435, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+414
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 435, 435
                    , 414, 435, 414, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 435, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+435
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+435, sellCostMeanBuyPrice = sellCostMeanBuyPrice+414
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+435, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+414
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '9', storedetaildate = '2024-12-20 19:25:30' WHERE storedetailid = '16254';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16255', '1', '1', '1', '150485', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '9', '2024-12-20 19:25:30','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2415',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('1815','600', '0', '1', 'اضافة فاتورة مبيعات', '150485', '2415', '2024-12-20 19:25:30', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 3 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 600, 435, 435
                    , 414, 435, 414, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,435, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+435
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+435, sellCostMeanBuyPrice = sellCostMeanBuyPrice+414
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+435, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+414
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 435, 435
                    , 414, 435, 414, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,435, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+435
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+435, sellCostMeanBuyPrice = sellCostMeanBuyPrice+414
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+435, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+414
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 600, 435, 435
                    , 414, 435, 414, 440, 435, 480)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+600, netSellCostBuyPrice = netSellCostBuyPrice+435
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+435
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+414
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+435
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+414
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+440
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+435
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+480;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765a7b71a490 and sellbillId = 150485 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:55:31";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:25:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:25:31', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:55:49";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:25:49", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:25:49', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a7ff1cb4b', '2024-12-20 19:23:11', '19', '293895.00', '308820', '0', '0', '14925',  '14925', '0', '14925', '1', '2024-12-20 19:25:49', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07348', '14191', '5', '16547', '15', '220', '3300', '0', '', '2024-12-20 19:25:49', '16547','','','0','0','0','0','0',null,'220','3300','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:23:11', 1, 16547, 0, 0
                    , 220, 15, 0, 0, 77, '2024-12-20 19:25:49')
                ON DUPLICATE KEY UPDATE buyprice = 220,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:25:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16547', '220', '15', '0', 'buyBillController.php', '32846', '', '0', '0');
UPDATE product SET  productBuyPrice = "220" WHERE productId = 16547 ;
UPDATE buybilldetail SET  quantitybefore = 15 WHERE buybilldetailid = 32846 ;
UPDATE product SET productName = '7348', productDescription = '', productCatId = '5', productBuyPrice = '220.00', productSellAllPrice = '285.00', productSellUnitPrice = '285.00', productSellHalfPrice = '285.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07348',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '220',lastbuyprice_withDiscount = '220',meanbuyprice = '221',meanbuyprice_withDiscount = '221' , productbuypricereal = '225.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='225',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='220',meanbuyprice_withTax='223',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='220'  WHERE productId = '16547';
UPDATE buybilldetail SET  lastbuyprice = 220 , meanbuyprice = 221, lastbuyprice_withDiscount = 220, meanbuyprice_withDiscount = 221
        , lastbuyprice_withTax = 220, meanbuyprice_withTax = 223, lastbuyprice_withDiscountAndTax = 220
                where buybilldetailid = 32846;
UPDATE productunit SET proUnitBuyPrice  = 220 * productnumber WHERE productid = 16547;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16546';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16547', '1', '15', '0', '14191', 'اضافة فاتورة مشتريات', 'buyBillController.php', '15', '30', '77', '2024-12-20 19:23:11','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07265', '14191', '5', '16375', '15', '220', '3300', '0', '', '2024-12-20 19:25:49', '16375','','','0','0','0','0','0',null,'220','3300','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:23:11', 1, 16375, 0, 0
                    , 220, 15, 0, 0, 77, '2024-12-20 19:25:49')
                ON DUPLICATE KEY UPDATE buyprice = 220,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:25:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16375', '220', '15', '0', 'buyBillController.php', '32847', '', '0', '0');
UPDATE product SET  productBuyPrice = "220" WHERE productId = 16375 ;
UPDATE buybilldetail SET  quantitybefore = 22 WHERE buybilldetailid = 32847 ;
UPDATE product SET productName = '7265', productDescription = '', productCatId = '5', productBuyPrice = '220.00', productSellAllPrice = '265.00', productSellUnitPrice = '265.00', productSellHalfPrice = '265.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07265',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '220',lastbuyprice_withDiscount = '220',meanbuyprice = '219',meanbuyprice_withDiscount = '219' , productbuypricereal = '215.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='215',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='220',meanbuyprice_withTax='217',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='220'  WHERE productId = '16375';
UPDATE buybilldetail SET  lastbuyprice = 220 , meanbuyprice = 219, lastbuyprice_withDiscount = 220, meanbuyprice_withDiscount = 219
        , lastbuyprice_withTax = 220, meanbuyprice_withTax = 217, lastbuyprice_withDiscountAndTax = 220
                where buybilldetailid = 32847;
UPDATE productunit SET proUnitBuyPrice  = 220 * productnumber WHERE productid = 16375;
UPDATE storedetail SET  productquantity = '37', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16374';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16375', '1', '15', '0', '14191', 'اضافة فاتورة مشتريات', 'buyBillController.php', '22', '37', '77', '2024-12-20 19:23:11','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07367', '14191', '5', '16551', '15', '275', '4125', '0', '', '2024-12-20 19:25:49', '16551','','','0','0','0','0','0',null,'275','4125','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:23:11', 1, 16551, 0, 0
                    , 275, 15, 0, 0, 77, '2024-12-20 19:25:49')
                ON DUPLICATE KEY UPDATE buyprice = 275,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:25:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16551', '275', '15', '0', 'buyBillController.php', '32848', '', '0', '0');
UPDATE product SET  productBuyPrice = "275" WHERE productId = 16551 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32848 ;
UPDATE product SET productName = '7367', productDescription = '', productCatId = '5', productBuyPrice = '275.00', productSellAllPrice = '335.00', productSellUnitPrice = '335.00', productSellHalfPrice = '335.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07367',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '275',lastbuyprice_withDiscount = '275',meanbuyprice = '275',meanbuyprice_withDiscount = '275' , productbuypricereal = '275.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='275',meanbuyprice_withTax='275',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='275'  WHERE productId = '16551';
UPDATE buybilldetail SET  lastbuyprice = 275 , meanbuyprice = 275, lastbuyprice_withDiscount = 275, meanbuyprice_withDiscount = 275
        , lastbuyprice_withTax = 275, meanbuyprice_withTax = 275, lastbuyprice_withDiscountAndTax = 275
                where buybilldetailid = 32848;
UPDATE productunit SET proUnitBuyPrice  = 275 * productnumber WHERE productid = 16551;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16550';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16551', '1', '15', '0', '14191', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:23:11','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07295', '14191', '5', '16428', '10', '420', '4200', '0', '', '2024-12-20 19:25:49', '16428','','','0','0','0','0','0',null,'420','4200','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:23:11', 1, 16428, 0, 0
                    , 420, 10, 0, 0, 77, '2024-12-20 19:25:49')
                ON DUPLICATE KEY UPDATE buyprice = 420,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:25:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16428', '420', '10', '0', 'buyBillController.php', '32849', '', '0', '0');
UPDATE product SET  productBuyPrice = "420" WHERE productId = 16428 ;
UPDATE buybilldetail SET  quantitybefore = 26 WHERE buybilldetailid = 32849 ;
UPDATE product SET productName = '7295', productDescription = '', productCatId = '5', productBuyPrice = '420.00', productSellAllPrice = '500.00', productSellUnitPrice = '500.00', productSellHalfPrice = '500.00', productDate = '2024-12-13', conditions = '0', userId = '77', limitamount = '1', parcode = '07295',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '420',lastbuyprice_withDiscount = '420',meanbuyprice = '420',meanbuyprice_withDiscount = '420' , productbuypricereal = '420.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='420',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='420',meanbuyprice_withTax='420',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='420'  WHERE productId = '16428';
UPDATE buybilldetail SET  lastbuyprice = 420 , meanbuyprice = 420, lastbuyprice_withDiscount = 420, meanbuyprice_withDiscount = 420
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where buybilldetailid = 32849;
UPDATE productunit SET proUnitBuyPrice  = 420 * productnumber WHERE productid = 16428;
UPDATE storedetail SET  productquantity = '36', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16427';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16428', '1', '10', '0', '14191', 'اضافة فاتورة مشتريات', 'buyBillController.php', '26', '36', '77', '2024-12-20 19:23:11','0','0');
UPDATE supplier SET  suppliercurrentDebt = '308820',suppliercurrentDebtInCurrency= '308820' , userid = '77', supplierdate = '2024-12-20 19:25:49'   WHERE supplierid = '19';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('19', '293895.00', '14925', '0', 'اضافة فاتورة مشتريات', '14191', '308820', '2024-12-20 19:23:11', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','14925','1','293895','14925','308820','0');
update buybill set dailyentryid='0,' where buybillid=14191;
COMMIT;
UPDATE product SET overAllAveragePrice = 216.67 WHERE productId = 16375;UPDATE product SET overAllAveragePrice = 420 WHERE productId = 16428;UPDATE product SET overAllAveragePrice = 222.5 WHERE productId = 16547;UPDATE product SET overAllAveragePrice = 275 WHERE productId = 16551;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:55:50";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:25:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:25:50', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14191');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:56:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 19:26:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 19:26:00', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:56:23";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:26:23", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:26:23', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:56:57";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 19:26:57", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 19:26:57', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:57:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 19:27:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:27:00', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150297');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:58:38";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:28:38", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:28:38', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a8bfce14a', '2024-12-20 19:26:23', '19', '308820.00', '337020', '0', '0', '28200',  '28200', '0', '28200', '1', '2024-12-20 19:28:38', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07074', '14192', '5', '16052', '10', '350', '3500', '0', '', '2024-12-20 19:28:38', '16052','','','0','0','0','0','0',null,'350','3500','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:26:23', 1, 16052, 0, 0
                    , 350, 10, 0, 0, 77, '2024-12-20 19:28:38')
                ON DUPLICATE KEY UPDATE buyprice = 350,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:28:38' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16052', '350', '10', '0', 'buyBillController.php', '32850', '', '0', '0');
UPDATE product SET  productBuyPrice = "350" WHERE productId = 16052 ;
UPDATE buybilldetail SET  quantitybefore = 15 WHERE buybilldetailid = 32850 ;
UPDATE product SET productName = '7074', productDescription = '', productCatId = '5', productBuyPrice = '350.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2024-11-21', conditions = '0', userId = '77', limitamount = '1', parcode = '07074',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '350',lastbuyprice_withDiscount = '350',meanbuyprice = '350',meanbuyprice_withDiscount = '350' , productbuypricereal = '350.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='350',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='350',meanbuyprice_withTax='350',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='350'  WHERE productId = '16052';
UPDATE buybilldetail SET  lastbuyprice = 350 , meanbuyprice = 350, lastbuyprice_withDiscount = 350, meanbuyprice_withDiscount = 350
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 350, lastbuyprice_withDiscountAndTax = 350
                where buybilldetailid = 32850;
UPDATE productunit SET proUnitBuyPrice  = 350 * productnumber WHERE productid = 16052;
UPDATE storedetail SET  productquantity = '25', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16051';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16052', '1', '10', '0', '14192', 'اضافة فاتورة مشتريات', 'buyBillController.php', '15', '25', '77', '2024-12-20 19:26:23','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07295', '14192', '5', '16428', '10', '420', '4200', '0', '', '2024-12-20 19:28:38', '16428','','','0','0','0','0','0',null,'420','4200','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:26:23', 1, 16428, 0, 0
                    , 420, 10, 0, 0, 77, '2024-12-20 19:28:38')
                ON DUPLICATE KEY UPDATE buyprice = 420,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:28:38' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16428', '420', '10', '0', 'buyBillController.php', '32851', '', '0', '0');
UPDATE product SET  productBuyPrice = "420" WHERE productId = 16428 ;
UPDATE buybilldetail SET  quantitybefore = 36 WHERE buybilldetailid = 32851 ;
UPDATE product SET productName = '7295', productDescription = '', productCatId = '5', productBuyPrice = '420.00', productSellAllPrice = '500.00', productSellUnitPrice = '500.00', productSellHalfPrice = '500.00', productDate = '2024-12-13', conditions = '0', userId = '77', limitamount = '1', parcode = '07295',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '420',lastbuyprice_withDiscount = '420',meanbuyprice = '420',meanbuyprice_withDiscount = '420' , productbuypricereal = '420.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='420',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='420',meanbuyprice_withTax='420',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='420'  WHERE productId = '16428';
UPDATE buybilldetail SET  lastbuyprice = 420 , meanbuyprice = 420, lastbuyprice_withDiscount = 420, meanbuyprice_withDiscount = 420
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where buybilldetailid = 32851;
UPDATE productunit SET proUnitBuyPrice  = 420 * productnumber WHERE productid = 16428;
UPDATE storedetail SET  productquantity = '46', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16427';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16428', '1', '10', '0', '14192', 'اضافة فاتورة مشتريات', 'buyBillController.php', '36', '46', '77', '2024-12-20 19:26:23','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('R3341', '14192', '1', '16440', '10', '400', '4000', '0', '', '2024-12-20 19:28:38', '16440','','','0','0','0','0','0',null,'400','4000','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:26:23', 1, 16440, 0, 0
                    , 400, 10, 0, 0, 77, '2024-12-20 19:28:38')
                ON DUPLICATE KEY UPDATE buyprice = 400,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:28:38' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16440', '400', '10', '0', 'buyBillController.php', '32852', '', '0', '0');
UPDATE product SET  productBuyPrice = "400" WHERE productId = 16440 ;
UPDATE buybilldetail SET  quantitybefore = 46 WHERE buybilldetailid = 32852 ;
UPDATE product SET productName = 'R3341', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '500.00', productSellUnitPrice = '500.00', productSellHalfPrice = '500.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3341',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '400',lastbuyprice_withDiscount = '400',meanbuyprice = '400',meanbuyprice_withDiscount = '400' , productbuypricereal = '400.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='400',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='400',meanbuyprice_withTax='400',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='400'  WHERE productId = '16440';
UPDATE buybilldetail SET  lastbuyprice = 400 , meanbuyprice = 400, lastbuyprice_withDiscount = 400, meanbuyprice_withDiscount = 400
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where buybilldetailid = 32852;
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 16440;
UPDATE storedetail SET  productquantity = '56', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16439';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16440', '1', '10', '0', '14192', 'اضافة فاتورة مشتريات', 'buyBillController.php', '46', '56', '77', '2024-12-20 19:26:23','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07293', '14192', '5', '16434', '15', '145', '2175', '0', '', '2024-12-20 19:28:38', '16434','','','0','0','0','0','0',null,'145','2175','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:26:23', 1, 16434, 0, 0
                    , 145, 15, 0, 0, 77, '2024-12-20 19:28:38')
                ON DUPLICATE KEY UPDATE buyprice = 145,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:28:38' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16434', '145', '15', '0', 'buyBillController.php', '32853', '', '0', '0');
UPDATE product SET  productBuyPrice = "145" WHERE productId = 16434 ;
UPDATE buybilldetail SET  quantitybefore = -2 WHERE buybilldetailid = 32853 ;
UPDATE product SET productName = '7293', productDescription = '', productCatId = '5', productBuyPrice = '145.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-13', conditions = '0', userId = '77', limitamount = '1', parcode = '07293',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '145',lastbuyprice_withDiscount = '145',meanbuyprice = '145',meanbuyprice_withDiscount = '145' , productbuypricereal = '145.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='145',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='145',meanbuyprice_withTax='145',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='145'  WHERE productId = '16434';
UPDATE buybilldetail SET  lastbuyprice = 145 , meanbuyprice = 145, lastbuyprice_withDiscount = 145, meanbuyprice_withDiscount = 145
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where buybilldetailid = 32853;
UPDATE productunit SET proUnitBuyPrice  = 145 * productnumber WHERE productid = 16434;
UPDATE storedetail SET  productquantity = '13', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16434', '1', '15', '0', '14192', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-2', '13', '77', '2024-12-20 19:26:23','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07291', '14192', '5', '16416', '15', '330', '4950', '0', '', '2024-12-20 19:28:38', '16416','','','0','0','0','0','0',null,'330','4950','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:26:23', 1, 16416, 0, 0
                    , 330, 15, 0, 0, 77, '2024-12-20 19:28:38')
                ON DUPLICATE KEY UPDATE buyprice = 330,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:28:38' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16416', '330', '15', '0', 'buyBillController.php', '32854', '', '0', '0');
UPDATE product SET  productBuyPrice = "330" WHERE productId = 16416 ;
UPDATE buybilldetail SET  quantitybefore = 3 WHERE buybilldetailid = 32854 ;
UPDATE product SET productName = '7291', productDescription = '', productCatId = '5', productBuyPrice = '330.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07291',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '330',lastbuyprice_withDiscount = '330',meanbuyprice = '330',meanbuyprice_withDiscount = '330' , productbuypricereal = '330.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='330',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='330',meanbuyprice_withTax='330',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='330'  WHERE productId = '16416';
UPDATE buybilldetail SET  lastbuyprice = 330 , meanbuyprice = 330, lastbuyprice_withDiscount = 330, meanbuyprice_withDiscount = 330
        , lastbuyprice_withTax = 330, meanbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 330
                where buybilldetailid = 32854;
UPDATE productunit SET proUnitBuyPrice  = 330 * productnumber WHERE productid = 16416;
UPDATE storedetail SET  productquantity = '18', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16415';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16416', '1', '15', '0', '14192', 'اضافة فاتورة مشتريات', 'buyBillController.php', '3', '18', '77', '2024-12-20 19:26:23','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('10445', '14192', '5', '16347', '15', '140', '2100', '0', '', '2024-12-20 19:28:38', '16347','','','0','0','0','0','0',null,'140','2100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:26:23', 1, 16347, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-20 19:28:38')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:28:38' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16347', '140', '15', '0', 'buyBillController.php', '32855', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16347 ;
UPDATE buybilldetail SET  quantitybefore = 7 WHERE buybilldetailid = 32855 ;
UPDATE product SET productName = '7230', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-09', conditions = '0', userId = '77', limitamount = '0', parcode = '10445',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '139',meanbuyprice_withDiscount = '139' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='140',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',barcodeInTax='',productNameE='',partNumber='0',vehicleType='-1',company='-1',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='138',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '16347';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 139, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 139
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 138, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32855;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16347;
UPDATE storedetail SET  productquantity = '22', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '15', '0', '14192', 'اضافة فاتورة مشتريات', 'buyBillController.php', '7', '22', '77', '2024-12-20 19:26:23','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07118', '14192', '5', '16125', '15', '155', '2325', '0', '', '2024-12-20 19:28:38', '16125','','','0','0','0','0','0',null,'155','2325','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:26:23', 1, 16125, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-20 19:28:38')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:28:38' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16125', '155', '15', '0', 'buyBillController.php', '32856', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 16125 ;
UPDATE buybilldetail SET  quantitybefore = 5 WHERE buybilldetailid = 32856 ;
UPDATE product SET productName = '7118', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-11-26', conditions = '0', userId = '77', limitamount = '1', parcode = '07118',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '155.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='155',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '16125';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32856;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 16125;
UPDATE storedetail SET  productquantity = '20', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16124';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16125', '1', '15', '0', '14192', 'اضافة فاتورة مشتريات', 'buyBillController.php', '5', '20', '77', '2024-12-20 19:26:23','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07287', '14192', '5', '16418', '10', '495', '4950', '0', '', '2024-12-20 19:28:38', '16418','','','0','0','0','0','0',null,'495','4950','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:26:23', 1, 16418, 0, 0
                    , 495, 10, 0, 0, 77, '2024-12-20 19:28:38')
                ON DUPLICATE KEY UPDATE buyprice = 495,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:28:38' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16418', '495', '10', '0', 'buyBillController.php', '32857', '', '0', '0');
UPDATE product SET  productBuyPrice = "495" WHERE productId = 16418 ;
UPDATE buybilldetail SET  quantitybefore = 2 WHERE buybilldetailid = 32857 ;
UPDATE product SET productName = '7287', productDescription = '', productCatId = '5', productBuyPrice = '495.00', productSellAllPrice = '580.00', productSellUnitPrice = '580.00', productSellHalfPrice = '580.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07287',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '495',lastbuyprice_withDiscount = '495',meanbuyprice = '495',meanbuyprice_withDiscount = '495' , productbuypricereal = '495.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='495',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='495',meanbuyprice_withTax='495',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='495'  WHERE productId = '16418';
UPDATE buybilldetail SET  lastbuyprice = 495 , meanbuyprice = 495, lastbuyprice_withDiscount = 495, meanbuyprice_withDiscount = 495
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 495, lastbuyprice_withDiscountAndTax = 495
                where buybilldetailid = 32857;
UPDATE productunit SET proUnitBuyPrice  = 495 * productnumber WHERE productid = 16418;
UPDATE storedetail SET  productquantity = '12', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16417';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16418', '1', '10', '0', '14192', 'اضافة فاتورة مشتريات', 'buyBillController.php', '2', '12', '77', '2024-12-20 19:26:23','0','0');
UPDATE supplier SET  suppliercurrentDebt = '337020',suppliercurrentDebtInCurrency= '337020' , userid = '77', supplierdate = '2024-12-20 19:28:38'   WHERE supplierid = '19';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('19', '308820.00', '28200', '0', 'اضافة فاتورة مشتريات', '14192', '337020', '2024-12-20 19:26:23', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','28200','1','308820','28200','337020','0');
update buybill set dailyentryid='0,' where buybillid=14192;
COMMIT;
UPDATE product SET overAllAveragePrice = 350 WHERE productId = 16052;UPDATE product SET overAllAveragePrice = 155 WHERE productId = 16125;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16347;UPDATE product SET overAllAveragePrice = 330 WHERE productId = 16416;UPDATE product SET overAllAveragePrice = 495 WHERE productId = 16418;UPDATE product SET overAllAveragePrice = 420 WHERE productId = 16428;UPDATE product SET overAllAveragePrice = 145 WHERE productId = 16434;UPDATE product SET overAllAveragePrice = 400 WHERE productId = 16440;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:58:38";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:28:38", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:28:38', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14192');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:59:07";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 19:29:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 19:29:07', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:59:24";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 19:29:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 19:29:24', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 15:59:46";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 19:29:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 19:29:46', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:00:03";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 19:30:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 19:30:03', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248094
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3434,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 19:30:03', userid = '2' WHERE clientid = '3434';
UPDATE client SET  inUse = 0 where clientid = 3434;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3434','601.00','601','1','ايصال تحصيل (( قبض من عميل ))','248094', '0', '2024-12-20 19:29:46', '2', 'clientPayedDeptController.php', '   ', '601', '0', null, '0', null, null,'', '-1','1','1','601','1','','3683','0');
UPDATE save SET  savecurrentvalue = '176880.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('176279.50','601', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248094', '176880.5', '2024-12-20 19:30:03', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '601', '601', '2024-12-20', '2', '0', '0', '2024-12-20 19:30:03','اضافة ايصال سداد للعميل فاتن دمياط E316','1','0','0','0','248094','clientPayedDeptController.php?do=show&id=248094');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122352', '-1', '601', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '601', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122352', '-1', '601', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-601', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '3434', clientdebtchangebefore = '601.000', clientdebtchangeamount = '601.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248094', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 19:29:46', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '601.00',discount='', reciptid='0', dailyentryid = '122352',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='601',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248094';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248094 -clientdebtchangeId = 248094
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:00:04";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 19:30:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 19:30:04', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:00:47";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:30:47", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:30:47', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7356','','5','140','200', '200','200', '2024-12-20', '0', '77', '1', '07356', '0', '0', '0', '0', '0', '140','140','140','140','140','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','140','140','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16552, 1,'2024-12-20 19:32:18',77)
                ON DUPLICATE KEY UPDATE productid = 16552, edited = 1, sysdate = '2024-12-20 19:32:18', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16552', '1', '2024-12-20', '77', '0','1655201','200','200','200','140','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16552', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16552', '1', '0', '0', '16552', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7369','','5','140','200', '200','200', '2024-12-20', '0', '77', '1', '07369', '0', '0', '0', '0', '0', '140','140','140','140','140','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','140','140','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16553, 1,'2024-12-20 19:33:16',77)
                ON DUPLICATE KEY UPDATE productid = 16553, edited = 1, sysdate = '2024-12-20 19:33:16', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16553', '1', '2024-12-20', '77', '0','1655301','200','200','200','140','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16553', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16553', '1', '0', '0', '16553', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:03:24";
UPDATE user SET loginip = "192.168.1.31", lastactivetime = "2024-12-20 19:33:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:33:24', '2', 'show', '192.168.1.31', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:03:35";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:33:35", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:33:35', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765a680d2a54
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 19:16:48', '06765a680d2a54', '1', '0.00', '0', '0', '1', '450.00', '450', '450', '0', '1', '2024-12-20 19:33:36', '', '9', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','450','0','','0','0','450','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150486', '0', '2024-12-20 19:33:36', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '450', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 19:16:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35646;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('375','H1569', '150486', '14', '16178', '1', '450', '450', '0', '', '1', '2024-12-20 19:33:36', '16178', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35646-1,','1','1','0','0','450','450','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 375.00 , meanbuyprice = 375.00, lastbuyprice_withDiscount = 375.00, meanbuyprice_withDiscount = 375.00
        , lastbuyprice_withTax = 375, meanbuyprice_withTax = 375, lastbuyprice_withDiscountAndTax = 375
                where sellbilldetailid = 549857;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16178, '2024-12-20', 450, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+375
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+375
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+375
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 450, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+375
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+375
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+375
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '53', userid = '9', storedetaildate = '2024-12-20 19:33:36' WHERE storedetailid = '16177';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16178', '1', '1', '1', '150486', 'اضافة فاتورة مبيعات', 'sellbillController.php', '54', '53', '9', '2024-12-20 19:33:36','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2865',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2415','450', '0', '1', 'اضافة فاتورة مبيعات', '150486', '2865', '2024-12-20 19:33:36', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 450, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+375
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+375
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+375
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 450, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+375
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+375
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+375
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 450, 375, 375
                    , 375, 375, 375, 375, 375, 375)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+450, netSellCostBuyPrice = netSellCostBuyPrice+375
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+375
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+375
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+375
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+375
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+375
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+375
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+375;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765a680d2a54 and sellbillId = 150486 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:03:36";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:33:36", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:33:36', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:03:41";
UPDATE user SET loginip = "192.168.1.31", lastactivetime = "2024-12-20 19:33:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:33:41', '2', 'show', '192.168.1.31', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7358','','5','140','200', '200','200', '2024-12-20', '0', '77', '1', '07358', '0', '0', '0', '0', '0', '140','140','140','140','140','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','140','140','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16554, 1,'2024-12-20 19:33:50',77)
                ON DUPLICATE KEY UPDATE productid = 16554, edited = 1, sysdate = '2024-12-20 19:33:50', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16554', '1', '2024-12-20', '77', '0','1655401','200','200','200','140','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16554', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16554', '1', '0', '0', '16554', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:04:08";
UPDATE user SET loginip = "192.168.1.31", lastactivetime = "2024-12-20 19:34:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:34:08', '2', 'editsellBill', '192.168.1.31', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150475');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7357','','5','140','200', '200','200', '2024-12-20', '0', '77', '1', '07357', '0', '0', '0', '0', '0', '140','140','140','140','140','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','140','140','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16555, 1,'2024-12-20 19:34:55',77)
                ON DUPLICATE KEY UPDATE productid = 16555, edited = 1, sysdate = '2024-12-20 19:34:55', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16555', '1', '2024-12-20', '77', '0','1655501','200','200','200','140','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16555', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16555', '1', '0', '0', '16555', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:05:15";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:35:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:35:15', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:05:21";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 19:35:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 19:35:21', '2', '', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:05:22";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:05:24";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 19:35:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 19:35:24', '2', 'show', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:06:16";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:36:16", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:36:16', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765aad39b22d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 19:35:15', '06765aad39b22d', '1', '0.00', '0', '0', '1', '980', '980', '-980', '0', '1', '2024-12-20 19:36:17', '', '9', '0', 'نقدي','1', '0', '5', '4', 'نقدي', '2', '0', '', '','','','-1','0','0','0','','0','-980','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16854', '0', '2024-12-20 19:36:17', '9', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '980', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 19:35:15','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('500.00', '07113', '16854', '5', '16201', '1', '570', '570', '0', '', '1', '0', '16201', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','570','570','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 497.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 497.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 497, lastbuyprice_withDiscountAndTax = 500
                where returnsellbilldetailid = 22044;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16201, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 570, 500, 500, 497
                    , 500, 497, 498.33, 0, 1, 0, 0, 500, 497)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+570, returnSellCostBuyPrice = returnSellCostBuyPrice+500, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+500
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+497, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+500
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+497
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+498.33
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+500
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+497
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 570, 500, 500, 497
                    , 500, 497, 498.33, 0, 0, 500, 497)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+570, returnSellCostBuyPrice = returnSellCostBuyPrice+500, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+500
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+497, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+500
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+497
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+498.33
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+500
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+497;
UPDATE storedetail SET  productquantity = '15', userid = '9', storedetaildate = '2024-12-20 19:36:17' WHERE storedetailid = '16200';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16201', '1', '1', '0', '16854', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '14', '15', '9', '2024-12-20 19:36:17','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('350.00', '07112', '16854', '5', '16198', '1', '410', '410', '0', '', '1', '0', '16198', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','410','410','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 350, lastbuyprice_withDiscountAndTax = 350
                where returnsellbilldetailid = 22045;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16198, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 410, 350, 350, 350
                    , 350, 350, 350, 0, 1, 0, 0, 350, 350)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+410, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+350
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+350
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+350
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 410, 350, 350, 350
                    , 350, 350, 350, 0, 0, 350, 350)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+410, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+350
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+350
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+350;
UPDATE storedetail SET  productquantity = '4', userid = '9', storedetaildate = '2024-12-20 19:36:17' WHERE storedetailid = '16197';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16198', '1', '1', '0', '16854', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '3', '4', '9', '2024-12-20 19:36:17','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '1885',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2865','-980', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16854', '1885', '2024-12-20 19:36:17', '9',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 980, 850, 850, 847
                    , 850, 847, 848.33 ,0, 0, 850, 847)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+980, returnSellCostBuyPrice = returnSellCostBuyPrice+850, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+850
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+847, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+850
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+847
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+848.33
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+850
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+847;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 980, 850, 850, 847
                    , 850, 847, 848.33 ,0, 0, 850, 847)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+980, returnSellCostBuyPrice = returnSellCostBuyPrice+850, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+850
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+847, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+850
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+847
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+848.33
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+850
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+847;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -980, -850, -850
                    , -847, -850, -847, -848.33, -850, -847)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-980, netSellCostBuyPrice = netSellCostBuyPrice+-850
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-850
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-847
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-850
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-847
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-848.33
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-850
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-847;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765aad39b22d and sellbillId = 16854 and returnsellbillId = 16854
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:06:17";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:36:17", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:36:17', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('H1696','','14','185','245', '245','245', '2024-12-20', '0', '77', '1', 'H1696', '0', '0', '0', '0', '0', '185','185','185','185','185','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','185','185','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16556, 1,'2024-12-20 19:36:21',77)
                ON DUPLICATE KEY UPDATE productid = 16556, edited = 1, sysdate = '2024-12-20 19:36:21', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16556', '1', '2024-12-20', '77', '0','1655601','245','245','245','185','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16556', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16556', '1', '0', '0', '16556', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:06:28";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:36:28", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:36:28', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a9c76f807', '2024-12-20 19:30:47', '19', '337020.00', '370845', '0', '0', '33825',  '33825', '0', '33825', '1', '2024-12-20 19:36:29', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07118', '14193', '5', '16125', '15', '155', '2325', '0', '', '2024-12-20 19:36:29', '16125','','','0','0','0','0','0',null,'155','2325','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 16125, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16125', '155', '15', '0', 'buyBillController.php', '32858', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 16125 ;
UPDATE buybilldetail SET  quantitybefore = 20 WHERE buybilldetailid = 32858 ;
UPDATE product SET productName = '7118', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-11-26', conditions = '0', userId = '77', limitamount = '1', parcode = '07118',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '155.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='155',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '16125';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32858;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 16125;
UPDATE storedetail SET  productquantity = '35', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16124';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16125', '1', '15', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '20', '35', '77', '2024-12-20 19:30:47','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06987', '14193', '5', '15947', '15', '155', '2325', '0', '', '2024-12-20 19:36:29', '15947','','','0','0','0','0','0',null,'155','2325','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 15947, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15947', '155', '15', '0', 'buyBillController.php', '32859', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 15947 ;
UPDATE buybilldetail SET  quantitybefore = 12 WHERE buybilldetailid = 32859 ;
UPDATE product SET productName = '6987', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-11-11', conditions = '0', userId = '77', limitamount = '1', parcode = '06987',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='155',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '15947';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32859;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 15947;
UPDATE storedetail SET  productquantity = '27', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '15946';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15947', '1', '15', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '12', '27', '77', '2024-12-20 19:30:47','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07264', '14193', '5', '16385', '30', '140', '4200', '0', '', '2024-12-20 19:36:29', '16385','','','0','0','0','0','0',null,'140','4200','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 16385, 0, 0
                    , 140, 30, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16385', '140', '30', '0', 'buyBillController.php', '32860', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16385 ;
UPDATE buybilldetail SET  quantitybefore = 19 WHERE buybilldetailid = 32860 ;
UPDATE product SET productName = '7264', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07264',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140',meanbuyprice_withDiscount = '140' , productbuypricereal = '140.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='140',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='132',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '16385';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 132, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32860;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16385;
UPDATE storedetail SET  productquantity = '49', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16384';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16385', '1', '30', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '19', '49', '77', '2024-12-20 19:30:47','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07356', '14193', '5', '16552', '15', '140', '2100', '0', '', '2024-12-20 19:36:29', '16552','','','0','0','0','0','0',null,'140','2100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 16552, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16552', '140', '15', '0', 'buyBillController.php', '32861', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16552 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32861 ;
UPDATE product SET productName = '7356', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07356',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140',meanbuyprice_withDiscount = '140' , productbuypricereal = '140.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='140',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '16552';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32861;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16552;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16551';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16552', '1', '15', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:30:47','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07359', '14193', '5', '16535', '15', '140', '2100', '0', '', '2024-12-20 19:36:29', '16535','','','0','0','0','0','0',null,'140','2100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 16535, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16535', '140', '15', '0', 'buyBillController.php', '32862', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16535 ;
UPDATE buybilldetail SET  quantitybefore = 15 WHERE buybilldetailid = 32862 ;
UPDATE product SET productName = '7359', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07359',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140',meanbuyprice_withDiscount = '140' , productbuypricereal = '140.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='140',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='140',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '16535';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32862;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16535;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16534';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16535', '1', '15', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '15', '30', '77', '2024-12-20 19:30:47','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07369', '14193', '5', '16553', '15', '140', '2100', '0', '', '2024-12-20 19:36:29', '16553','','','0','0','0','0','0',null,'140','2100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 16553, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16553', '140', '15', '0', 'buyBillController.php', '32863', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16553 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32863 ;
UPDATE product SET productName = '7369', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07369',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140',meanbuyprice_withDiscount = '140' , productbuypricereal = '140.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='140',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '16553';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32863;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16553;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16552';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16553', '1', '15', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:30:47','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06934', '14193', '5', '15820', '15', '140', '2100', '0', '', '2024-12-20 19:36:29', '15820','','','0','0','0','0','0',null,'140','2100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 15820, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15820', '140', '15', '0', 'buyBillController.php', '32864', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 15820 ;
UPDATE buybilldetail SET  quantitybefore = 1 WHERE buybilldetailid = 32864 ;
UPDATE product SET productName = '6934', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-11-01', conditions = '0', userId = '77', limitamount = '1', parcode = '06934',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140',meanbuyprice_withDiscount = '140' , productbuypricereal = '145.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='141.11',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='140',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '15820';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32864;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 15820;
UPDATE storedetail SET  productquantity = '16', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '15819';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15820', '1', '15', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '1', '16', '77', '2024-12-20 19:30:47','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07358', '14193', '5', '16554', '15', '140', '2100', '0', '', '2024-12-20 19:36:29', '16554','','','0','0','0','0','0',null,'140','2100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 16554, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16554', '140', '15', '0', 'buyBillController.php', '32865', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16554 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32865 ;
UPDATE product SET productName = '7358', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07358',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140',meanbuyprice_withDiscount = '140' , productbuypricereal = '140.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='140',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '16554';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32865;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16554;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16553';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16554', '1', '15', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:30:47','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07357', '14193', '5', '16555', '15', '140', '2100', '0', '', '2024-12-20 19:36:29', '16555','','','0','0','0','0','0',null,'140','2100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 16555, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16555', '140', '15', '0', 'buyBillController.php', '32866', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16555 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32866 ;
UPDATE product SET productName = '7357', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07357',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140',meanbuyprice_withDiscount = '140' , productbuypricereal = '140.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='140',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '16555';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32866;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16555;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16554';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16555', '1', '15', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:30:47','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07314', '14193', '5', '16485', '15', '140', '2100', '0', '', '2024-12-20 19:36:29', '16485','','','0','0','0','0','0',null,'140','2100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 16485, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16485', '140', '15', '0', 'buyBillController.php', '32867', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16485 ;
UPDATE buybilldetail SET  quantitybefore = 15 WHERE buybilldetailid = 32867 ;
UPDATE product SET productName = '7314', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07314',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140',meanbuyprice_withDiscount = '140' , productbuypricereal = '140.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='140',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='140',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '16485';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32867;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16485;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16484';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16485', '1', '15', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '15', '30', '77', '2024-12-20 19:30:47','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07295', '14193', '5', '16428', '10', '420', '4200', '0', '', '2024-12-20 19:36:29', '16428','','','0','0','0','0','0',null,'420','4200','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 16428, 0, 0
                    , 420, 10, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 420,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16428', '420', '10', '0', 'buyBillController.php', '32868', '', '0', '0');
UPDATE product SET  productBuyPrice = "420" WHERE productId = 16428 ;
UPDATE buybilldetail SET  quantitybefore = 46 WHERE buybilldetailid = 32868 ;
UPDATE product SET productName = '7295', productDescription = '', productCatId = '5', productBuyPrice = '420.00', productSellAllPrice = '500.00', productSellUnitPrice = '500.00', productSellHalfPrice = '500.00', productDate = '2024-12-13', conditions = '0', userId = '77', limitamount = '1', parcode = '07295',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '420',lastbuyprice_withDiscount = '420',meanbuyprice = '420',meanbuyprice_withDiscount = '420' , productbuypricereal = '420.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='420',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='420',meanbuyprice_withTax='420',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='420'  WHERE productId = '16428';
UPDATE buybilldetail SET  lastbuyprice = 420 , meanbuyprice = 420, lastbuyprice_withDiscount = 420, meanbuyprice_withDiscount = 420
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where buybilldetailid = 32868;
UPDATE productunit SET proUnitBuyPrice  = 420 * productnumber WHERE productid = 16428;
UPDATE storedetail SET  productquantity = '56', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16427';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16428', '1', '10', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '46', '56', '77', '2024-12-20 19:30:47','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07338', '14193', '5', '16548', '15', '220', '3300', '0', '', '2024-12-20 19:36:29', '16548','','','0','0','0','0','0',null,'220','3300','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 16548, 0, 0
                    , 220, 15, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 220,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16548', '220', '15', '0', 'buyBillController.php', '32869', '', '0', '0');
UPDATE product SET  productBuyPrice = "220" WHERE productId = 16548 ;
UPDATE buybilldetail SET  quantitybefore = 15 WHERE buybilldetailid = 32869 ;
UPDATE product SET productName = '7338', productDescription = '', productCatId = '5', productBuyPrice = '220.00', productSellAllPrice = '280.00', productSellUnitPrice = '280.00', productSellHalfPrice = '280.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07338',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '220',lastbuyprice_withDiscount = '220',meanbuyprice = '220',meanbuyprice_withDiscount = '220' , productbuypricereal = '220.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='220',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='220',meanbuyprice_withTax='220',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='220'  WHERE productId = '16548';
UPDATE buybilldetail SET  lastbuyprice = 220 , meanbuyprice = 220, lastbuyprice_withDiscount = 220, meanbuyprice_withDiscount = 220
        , lastbuyprice_withTax = 220, meanbuyprice_withTax = 220, lastbuyprice_withDiscountAndTax = 220
                where buybilldetailid = 32869;
UPDATE productunit SET proUnitBuyPrice  = 220 * productnumber WHERE productid = 16548;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16547';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16548', '1', '15', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '15', '30', '77', '2024-12-20 19:30:47','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1696', '14193', '14', '16556', '15', '185', '2775', '0', '', '2024-12-20 19:36:29', '16556','','','0','0','0','0','0',null,'185','2775','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:30:47', 1, 16556, 0, 0
                    , 185, 15, 0, 0, 77, '2024-12-20 19:36:29')
                ON DUPLICATE KEY UPDATE buyprice = 185,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:36:29' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16556', '185', '15', '0', 'buyBillController.php', '32870', '', '0', '0');
UPDATE product SET  productBuyPrice = "185" WHERE productId = 16556 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32870 ;
UPDATE product SET productName = 'H1696', productDescription = '', productCatId = '14', productBuyPrice = '185.00', productSellAllPrice = '245.00', productSellUnitPrice = '245.00', productSellHalfPrice = '245.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1696',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185',lastbuyprice_withDiscount = '185',meanbuyprice = '185',meanbuyprice_withDiscount = '185' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='185',meanbuyprice_withTax='185',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='185'  WHERE productId = '16556';
UPDATE buybilldetail SET  lastbuyprice = 185 , meanbuyprice = 185, lastbuyprice_withDiscount = 185, meanbuyprice_withDiscount = 185
        , lastbuyprice_withTax = 185, meanbuyprice_withTax = 185, lastbuyprice_withDiscountAndTax = 185
                where buybilldetailid = 32870;
UPDATE productunit SET proUnitBuyPrice  = 185 * productnumber WHERE productid = 16556;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16555';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16556', '1', '15', '0', '14193', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:30:47','0','0');
UPDATE supplier SET  suppliercurrentDebt = '370845',suppliercurrentDebtInCurrency= '370845' , userid = '77', supplierdate = '2024-12-20 19:36:29'   WHERE supplierid = '19';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('19', '337020.00', '33825', '0', 'اضافة فاتورة مشتريات', '14193', '370845', '2024-12-20 19:30:47', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','33825','1','337020','33825','370845','0');
update buybill set dailyentryid='0,' where buybillid=14193;
COMMIT;
UPDATE product SET overAllAveragePrice = 141 WHERE productId = 15820;UPDATE product SET overAllAveragePrice = 155 WHERE productId = 15947;UPDATE product SET overAllAveragePrice = 155 WHERE productId = 16125;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16385;UPDATE product SET overAllAveragePrice = 420 WHERE productId = 16428;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16485;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16535;UPDATE product SET overAllAveragePrice = 220 WHERE productId = 16548;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16552;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16553;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16554;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16555;UPDATE product SET overAllAveragePrice = 185 WHERE productId = 16556;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:06:30";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:36:30", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:36:30', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14193');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:06:58";
UPDATE user SET loginip = "192.168.1.31", lastactivetime = "2024-12-20 19:36:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:36:58', '2', 'update', '192.168.1.31', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 150475 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 150475 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150475;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 19:36:59', userid = '101',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '150475';
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        
                where sellbilldetailid = 549820;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15283, '2024-12-20', 325, 280, 280
                    , 280, 280, 280, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-325, sellCostBuyPrice =sellCostBuyPrice-280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-280, sellCostMeanBuyPrice = sellCostMeanBuyPrice-280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 325, 280, 280
                    , 280, 280, 280, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-325, sellCostBuyPrice =sellCostBuyPrice-280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-280, sellCostMeanBuyPrice = sellCostMeanBuyPrice-280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-5', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '15282';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15283', '1', '1', '0', '150475', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-6', '-5', '2', '2024-12-20 18:28:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 29854;
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 565.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 565.00
        
                where sellbilldetailid = 549821;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13153, '2024-12-20', 310, 260, 260
                    , 565, 260, 565, 259.47
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-310, sellCostBuyPrice =sellCostBuyPrice-260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-260, sellCostMeanBuyPrice = sellCostMeanBuyPrice-565
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-565
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-259.47
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 310, 260, 260
                    , 565, 260, 565, 259.47
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-310, sellCostBuyPrice =sellCostBuyPrice-260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-260, sellCostMeanBuyPrice = sellCostMeanBuyPrice-565
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-565
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-259.47
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '37', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '13152';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13153', '1', '1', '0', '150475', 'تعديل فاتورة مبيعات', 'sellbillController.php', '36', '37', '2', '2024-12-20 18:28:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36346;
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549822;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16223, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-470, sellCostBuyPrice =sellCostBuyPrice-400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-400, sellCostMeanBuyPrice = sellCostMeanBuyPrice-400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-400
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-470, sellCostBuyPrice =sellCostBuyPrice-400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-400, sellCostMeanBuyPrice = sellCostMeanBuyPrice-400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-400
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '13', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '16222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16223', '1', '1', '0', '150475', 'تعديل فاتورة مبيعات', 'sellbillController.php', '12', '13', '2', '2024-12-20 18:28:15','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 495.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 495.00
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 71, lastbuyprice_withDiscountAndTax = 495
                where sellbilldetailid = 549823;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14340, '2024-12-20', 420, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 495, 71, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-495, sellCostMeanBuyPrice = sellCostMeanBuyPrice-495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-71
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 71, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-420, sellCostBuyPrice =sellCostBuyPrice-495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-495, sellCostMeanBuyPrice = sellCostMeanBuyPrice-495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-71
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-13', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '14339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14340', '1', '1', '0', '150475', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-14', '-13', '2', '2024-12-20 18:28:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 29022;
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 1560.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 1560.00
        
                where sellbilldetailid = 549824;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12941, '2024-12-20', 250, 240, 240
                    , 1560, 240, 1560, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-250, sellCostBuyPrice =sellCostBuyPrice-240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-240, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1560
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1560
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 250, 240, 240
                    , 1560, 240, 1560, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-250, sellCostBuyPrice =sellCostBuyPrice-240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-240, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1560
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1560
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-5', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '12940';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12941', '1', '1', '0', '150475', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-6', '-5', '2', '2024-12-20 18:28:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35973;
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 1105.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 1105.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 1710, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 549825;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16204, '2024-12-20', 610, 500, 500
                    , 1105, 500, 1105, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 500, 1710, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-610, sellCostBuyPrice =sellCostBuyPrice-500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1105
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1105
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1710
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 500, 500
                    , 1105, 500, 1105, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 1710, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-610, sellCostBuyPrice =sellCostBuyPrice-500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1105
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1105
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1710
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '-1', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '16203';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16204', '1', '1', '0', '150475', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-2', '-1', '2', '2024-12-20 18:28:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 34770;
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 190, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 549826;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15784, '2024-12-20', 240, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-240, sellCostBuyPrice =sellCostBuyPrice-190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-190, sellCostMeanBuyPrice = sellCostMeanBuyPrice-190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-190
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 240, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-240, sellCostBuyPrice =sellCostBuyPrice-190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-190, sellCostMeanBuyPrice = sellCostMeanBuyPrice-190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-190
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '3', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '15783';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15784', '1', '1', '0', '150475', 'تعديل فاتورة مبيعات', 'sellbillController.php', '2', '3', '2', '2024-12-20 18:28:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 22469;
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
        
                where sellbilldetailid = 549827;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10242, '2024-12-20', 155, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-155, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-155, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '3', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '10241';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10242', '1', '1', '0', '150475', 'تعديل فاتورة مبيعات', 'sellbillController.php', '2', '3', '2', '2024-12-20 18:28:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36103;
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 232, lastbuyprice_withDiscountAndTax = 230
                where sellbilldetailid = 549828;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16374, '2024-12-20', 300, 230, 230
                    , 230, 230, 230, 233
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 230, 232, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-300, sellCostBuyPrice =sellCostBuyPrice-230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-230, sellCostMeanBuyPrice = sellCostMeanBuyPrice-230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-233
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-232
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 230, 230
                    , 230, 230, 230, 233
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 232, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-300, sellCostBuyPrice =sellCostBuyPrice-230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-230, sellCostMeanBuyPrice = sellCostMeanBuyPrice-230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-233
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-232
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '57', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '16373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16374', '1', '1', '0', '150475', 'تعديل فاتورة مبيعات', 'sellbillController.php', '56', '57', '2', '2024-12-20 18:28:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35977;
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 503.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 503.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 507, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 549829;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16297, '2024-12-20', 580, 500, 500
                    , 503, 500, 503, 507.69
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 500, 507, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-580, sellCostBuyPrice =sellCostBuyPrice-500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-507.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-507
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 580, 500, 500
                    , 503, 500, 503, 507.69
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 507, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-580, sellCostBuyPrice =sellCostBuyPrice-500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-507.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-507
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '133', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '0', '150475', 'تعديل فاتورة مبيعات', 'sellbillController.php', '132', '133', '2', '2024-12-20 18:28:15','0','0');
CALL clientInUse(4241,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-3230', userid = '2' WHERE clientid = '4241';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4241','487.00','3717.00','1','تعديل فاتورة مبيعات','150475', '-3230', '2024-12-20 18:28:15', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '3717', '0', null, '0', null, null,'', '0','1','1','3717','1','2024-12-20 18:28:15','0','0');
UPDATE client SET  inUse = 0 where clientid = 4241;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 3717, 3315, 3315
                    , 5548, 3315, 5548, 3045.16
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2315, 3110, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-3717, sellCostBuyPrice =sellCostBuyPrice-3315
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-3315, sellCostMeanBuyPrice = sellCostMeanBuyPrice-5548
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-3315, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-5548
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-3045.16
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-2315
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-3110
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4241, '2024-12-20', 3717, 3315, 3315
                    , 5548, 3315, 5548, 3045.16
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2315, 3110, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-3717, sellCostBuyPrice =sellCostBuyPrice-3315
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-3315, sellCostMeanBuyPrice = sellCostMeanBuyPrice-5548
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-3315, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-5548
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-3045.16
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-2315
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-3110
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3717, 3315, 3315
                    , 5548, 3315, 5548, 3045.16, 2315, 3110)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-3717, netSellCostBuyPrice = netSellCostBuyPrice-3315
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-3315
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-5548
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-3315
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-5548
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-3045.16
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-2315
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-3110;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 150475 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 150475 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

COMMIT;
BEGIN;
CALL clientInUse(4241,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 18:28:15', '067659b1faafc5', '4241', '-3230.00', '113', '0', '1', '3343', '3343', '0', '3343', '1', '2024-12-20 18:28:15', '', '2', '0', 'بسنت عادل 25', '2', '1', '3', '88', 'بسنت عادل 25', '11', '150475', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '113', userid = '2' WHERE clientid = '4241';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4241','-3230.00','3343','0','اضافة فاتورة مبيعات (معدله)','150487', '113', '2024-12-20 19:36:59', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '3343', '0', null, '0', null, null,'', '0','1','1','3717','1','2024-12-20 18:28:15','0','0');
UPDATE client SET  inUse = 0 where clientid = 4241;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('280','R2941', '150487', '1', '15283', '1', '325', '325', '0', '', '1', '2024-12-20 19:36:59', '15283', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','325','325','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        
                where sellbilldetailid = 549858;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15283, '2024-12-20', 325, 280, 280
                    , 280, 280, 280, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 325, 280, 280
                    , 280, 280, 280, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-6', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '15282';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15283', '1', '1', '1', '150487', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '-5', '-6', '2', '2024-12-20 19:36:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29854;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('260','05891', '150487', '5', '13153', '1', '180', '180', '0', '', '1', '2024-12-20 19:36:59', '13153', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29854-1,','1','1','0','0','180','180','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 565.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 565.00
        
                where sellbilldetailid = 549859;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13153, '2024-12-20', 180, 260, 260
                    , 565, 260, 565, 259.47
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+565
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+565
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.47
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 180, 260, 260
                    , 565, 260, 565, 259.47
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+565
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+565
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.47
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '36', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '13152';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13153', '1', '1', '1', '150487', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '37', '36', '2', '2024-12-20 19:36:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36346;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('400','R3319', '150487', '1', '16223', '1', '470', '470', '0', '', '1', '2024-12-20 19:36:59', '16223', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36346-1,','1','1','0','0','470','470','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549860;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16223, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '16222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16223', '1', '1', '1', '150487', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '13', '12', '2', '2024-12-20 19:36:59','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('495','06307', '150487', '5', '14340', '1', '420', '420', '0', '', '1', '2024-12-20 19:36:59', '14340', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 495.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 495.00
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 71, lastbuyprice_withDiscountAndTax = 495
                where sellbilldetailid = 549861;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14340, '2024-12-20', 420, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 495, 71, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+71
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 420, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 71, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+71
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-14', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '14339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14340', '1', '1', '1', '150487', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '-13', '-14', '2', '2024-12-20 19:36:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29022;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','R2642', '150487', '1', '12941', '1', '250', '250', '0', '', '1', '2024-12-20 19:36:59', '12941', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29022-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 1560.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 1560.00
        
                where sellbilldetailid = 549862;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12941, '2024-12-20', 250, 240, 240
                    , 1560, 240, 1560, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1560
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1560
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 250, 240, 240
                    , 1560, 240, 1560, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1560
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1560
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-6', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '12940';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12941', '1', '1', '1', '150487', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '-5', '-6', '2', '2024-12-20 19:36:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35973;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('500','H1571', '150487', '14', '16204', '1', '610', '610', '0', '', '1', '2024-12-20 19:36:59', '16204', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35973-1,','1','1','0','0','610','610','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 1105.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 1105.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 1710, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 549863;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16204, '2024-12-20', 610, 500, 500
                    , 1105, 500, 1105, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 1710, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1105
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1105
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1710
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 500, 500
                    , 1105, 500, 1105, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 1710, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1105
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1105
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1710
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-2', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '16203';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16204', '1', '1', '1', '150487', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '-1', '-2', '2', '2024-12-20 19:36:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 22469;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('220','0K479', '150487', '7', '10242', '1', '155', '155', '0', '', '1', '2024-12-20 19:36:59', '10242', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','22469-1,','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
        
                where sellbilldetailid = 549864;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10242, '2024-12-20', 155, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 155, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '10241';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10242', '1', '1', '1', '150487', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '3', '2', '2', '2024-12-20 19:36:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36103;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','07260', '150487', '5', '16374', '1', '300', '300', '0', '', '1', '2024-12-20 19:36:59', '16374', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36103-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 232, lastbuyprice_withDiscountAndTax = 230
                where sellbilldetailid = 549865;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16374, '2024-12-20', 300, 230, 230
                    , 230, 230, 230, 233
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 230, 232, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+233
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+232
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 230, 230
                    , 230, 230, 230, 233
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 232, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+233
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+232
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '56', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '16373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16374', '1', '1', '1', '150487', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '57', '56', '2', '2024-12-20 19:36:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35977;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('510','07197', '150487', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-20 19:36:59', '16297', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35977-1,','1','1','0','0','580','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 503.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 503.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 507, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 549866;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16297, '2024-12-20', 580, 500, 500
                    , 503, 500, 503, 507.69
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 507, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+507.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+507
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 580, 500, 500
                    , 503, 500, 503, 507.69
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 507, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+507.69
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+507
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '132', userid = '2', storedetaildate = '2024-12-20 19:36:59' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '150487', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '133', '132', '2', '2024-12-20 19:36:59','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '150487', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-20 19:36:59', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '150487', '17', '10291', '1', '33', '33', '0', '', '1', '2024-12-20 19:36:59', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','33','33','0','','0','0.00','0','0','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 3343, 3125, 3125
                    , 5358, 3125, 5358, 2855.16
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2125, 2920, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3343, sellCostBuyPrice =sellCostBuyPrice+3125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+5358
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+5358
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2855.16
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2125
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2920
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4241, '2024-12-20', 3343, 3125, 3125
                    , 5358, 3125, 5358, 2855.16
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2125, 2920, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3343, sellCostBuyPrice =sellCostBuyPrice+3125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+5358
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+5358
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2855.16
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2125
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2920
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3343, 3125, 3125
                    , 5358, 3125, 5358, 2855.16, 2125, 2920)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3343, netSellCostBuyPrice = netSellCostBuyPrice+3125
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3125
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+5358
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3125
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+5358
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2855.16
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2125
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2920;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150475 and newid=150487 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:07:00";
UPDATE user SET loginip = "192.168.1.31", lastactivetime = "2024-12-20 19:37:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:37:00', '2', 'editprint', '192.168.1.31', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150487');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:08:18";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:38:18", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:38:18', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:08:39";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:38:39", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:38:39', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('06765ab8a87cb9', '2024-12-20 19:38:18', '19', '370845.00', '370425', '0', '0', '-420', '-420', '0', '-420', '1', '2024-12-20 19:38:39', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07037', '2538', '5', '15995', '1', '420', '420', '0', '', '15995','','','0','0','0','0','0','420','420','0','0','0','0','0','0','0');
UPDATE product SET productName = '7037', productDescription = '', productCatId = '5', productBuyPrice = '420.00', productSellAllPrice = '480.00', productSellUnitPrice = '480.00', productSellHalfPrice = '480.00', productDate = '2024-11-16', conditions = '0', userId = '77', limitamount = '1', parcode = '07037',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '420',lastbuyprice_withDiscount = '420',meanbuyprice = '420',meanbuyprice_withDiscount = '420' , productbuypricereal = '420.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='420',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='420',meanbuyprice_withTax='420',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='420'  WHERE productId = '15995';
UPDATE returnbuybilldetail SET  lastbuyprice = 420 , meanbuyprice = 420, lastbuyprice_withDiscount = 420, meanbuyprice_withDiscount = 420
        , lastbuyprice_withTax = 420, meanbuyprice_withTax = 420, lastbuyprice_withDiscountAndTax = 420
                where returnbuybilldetailid = 3977;
UPDATE productunit SET proUnitBuyPrice  = 420 * productnumber WHERE productid = 15995;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '2538', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '31', '30', '77', '2024-12-20 19:38:18','0','0');
UPDATE supplier SET  suppliercurrentDebt = '370425',suppliercurrentDebtInCurrency= '370425' , userid = '77', supplierdate = '2024-12-20 19:38:39'   WHERE supplierid = '19';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('19', '370845.00', '420', '1', 'اضافة فاتورة مردوات مشتريات', '2538', '370425', '2024-12-20 19:38:18', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','420','1','370845','420','370425','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2538;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:08:39";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:38:39", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 19:38:39', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2538');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:08:53";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 19:38:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 19:38:53', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:08:54";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:09:00";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 19:39:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 19:39:00', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:09:11";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:39:11", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:39:11', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:09:45";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:39:45", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 19:39:45', '77', 'show', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:09:49";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:39:49", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:39:49', '77', 'editreturn', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editreturn&id=2535');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:09:58";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:39:58", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:39:58', '77', 'update', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=update');
BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 4) and  modelid = 2535;
UPDATE returnbuybill SET  returnbuybillsysdate = '2024-12-20 19:39:58', userid = null,delbyuserid = '77', conditions = '1' WHERE returnbuybillid = '2535';
UPDATE product SET productName = 'H1623', productDescription = '', productCatId = '14', productBuyPrice = '440.00', productSellAllPrice = '530.00', productSellUnitPrice = '530.00', productSellHalfPrice = '530.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1623',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '440',lastbuyprice_withDiscount = '440',meanbuyprice = '440',meanbuyprice_withDiscount = '440' , productbuypricereal = '440.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='440',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='440',meanbuyprice_withTax='440',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='440'  WHERE productId = '16312';
UPDATE productunit SET proUnitBuyPrice  = 440 * productnumber WHERE productid = 16312;
UPDATE storedetail SET  productquantity = '16', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16311';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16312', '1', '15', '0', '2535', 'حذف فاتورة مردودات مشتريات', 'returnBuyBillController.php', '1', '16', '77', '2024-12-20 17:08:37','0','0');
UPDATE supplier SET  suppliercurrentDebt = '262140',suppliercurrentDebtInCurrency= '262140' , userid = '77', supplierdate = '2024-12-20 19:39:58'   WHERE supplierid = '7';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('7', '255540.00', '6600', '0', 'حذف فاتورة مردودات مشتريات', '2535', '262140', '2024-12-20 17:08:37', '77', 'returnBuyBillController.php', 'حذف فاتورة مردودات مشتريات', '0','', '0','1','1','6600','1','255540','-6600','262140','0');
UPDATE save SET  savecurrentvalue = '1885',  userid = '77' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('1885.00','0', '1', '1', 'حذف فاتورة مردودات مشتريات', '2535', '1885', '2024-12-20 17:08:37', '77',  'returnBuyBillController.php','0','','0');
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,deletedbuyid,controlname,payedtax,costcenterid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('067658875eed83', '2024-12-20 17:08:37', '78', '335400.00', '328800', '0', '0', '-6600', '-6600', '0.00', '-6600', '1', '2024-12-20 19:39:58', '', '77', '0', '', '1', '6' ,'1' ,'2535','returnBuyBillController.php','0.00','-1','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('H1623', '2539', '14', '16312', '15.00', '440', '6600', '0.00', '', '16312','','','0','0','0','0','0','440','6600','0','0','0','0','0','0','0');
UPDATE product SET productName = 'H1623', productDescription = '', productCatId = '14', productBuyPrice = '440.00', productSellAllPrice = '530.00', productSellUnitPrice = '530.00', productSellHalfPrice = '530.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1623',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '440',lastbuyprice_withDiscount = '0',meanbuyprice = '440',meanbuyprice_withDiscount = '440' , productbuypricereal = '440.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='440',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='440',meanbuyprice_withTax='440',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='0'  WHERE productId = '16312';
UPDATE returnbuybilldetail SET  lastbuyprice = 440 , meanbuyprice = 440, lastbuyprice_withDiscount = 0, meanbuyprice_withDiscount = 440
        , lastbuyprice_withTax = 440, meanbuyprice_withTax = 440
                where returnbuybilldetailid = 3978;
UPDATE productunit SET proUnitBuyPrice  = 440 * productnumber WHERE productid = 16312;
UPDATE storedetail SET  productquantity = '1', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16311';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16312', '1', '15', '1', '2539', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '16', '1', '77', '2024-12-20 17:08:37','0','0');
UPDATE supplier SET  suppliercurrentDebt = '328800',suppliercurrentDebtInCurrency= '328800' , userid = '77', supplierdate = '2024-12-20 19:39:58'   WHERE supplierid = '78';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('78', '335400.00', '6600', '1', 'اضافة فاتورة مردوات مشتريات', '2539', '328800', '2024-12-20 17:08:37', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','6600','1','335400','6600','328800','0');
UPDATE save SET  savecurrentvalue = '1885',  userid = '77' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('1885.00','0', '0', '1', 'اضافة فاتورة مردوات مشتريات', '2539', '1885', '2024-12-20 17:08:37', '77',  'returnBuyBillController.php','0','','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2539;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:09:58";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:39:58", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 19:39:58', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2539');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:10:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:40:27", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:40:27', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765abc020511
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 19:39:12', '06765abc020511', '1', '0.00', '0', '0', '1', '600.00', '600', '600', '0', '1', '2024-12-20 19:40:27', '', '9', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','600','0','','0','0','600','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150488', '0', '2024-12-20 19:40:27', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '600', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 19:39:12','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('190','R1681', '150488', '1', '7593', '1', '600', '600', '0', '', '1', '2024-12-20 19:40:27', '7593', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        
                where sellbilldetailid = 549869;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7593, '2024-12-20', 600, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '9', storedetaildate = '2024-12-20 19:40:27' WHERE storedetailid = '7592';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('7593', '1', '1', '1', '150488', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '9', '2024-12-20 19:40:27','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2485',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('1885','600', '0', '1', 'اضافة فاتورة مبيعات', '150488', '2485', '2024-12-20 19:40:27', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 600, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 600, 190, 190
                    , 190, 190, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+600, netSellCostBuyPrice = netSellCostBuyPrice+190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+190
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+190
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+190
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+190
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+190
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765abc020511 and sellbillId = 150488 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:10:28";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:40:28", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:40:28', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:10:30";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:40:30", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:40:30', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:10:47";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:40:47", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:40:47', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('06765ac0f1b10d', '2024-12-20 19:40:31', '7', '262140.00', '261870', '0', '0', '-270', '-270', '0', '-270', '1', '2024-12-20 19:40:47', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('R2922', '2540', '1', '14396', '1', '270', '270', '0', '', '14396','','','0','0','0','0','0','270','270','0','0','0','0','0','0','0');
UPDATE product SET productName = 'R2922', productDescription = '', productCatId = '1', productBuyPrice = '270.00', productSellAllPrice = '320.00', productSellUnitPrice = '320.00', productSellHalfPrice = '320.00', productDate = '2024-08-17', conditions = '0', userId = '77', limitamount = '1', parcode = 'R2922',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '270',lastbuyprice_withDiscount = '270',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '270.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='270',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='270',meanbuyprice_withTax='90',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='270'  WHERE productId = '14396';
UPDATE returnbuybilldetail SET  lastbuyprice = 270 , meanbuyprice = 270, lastbuyprice_withDiscount = 270, meanbuyprice_withDiscount = 270
        , lastbuyprice_withTax = 270, meanbuyprice_withTax = 90, lastbuyprice_withDiscountAndTax = 270
                where returnbuybilldetailid = 3979;
UPDATE productunit SET proUnitBuyPrice  = 270 * productnumber WHERE productid = 14396;
UPDATE storedetail SET  productquantity = '3', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '14395';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14396', '1', '1', '1', '2540', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '4', '3', '77', '2024-12-20 19:40:31','0','0');
UPDATE supplier SET  suppliercurrentDebt = '261870',suppliercurrentDebtInCurrency= '261870' , userid = '77', supplierdate = '2024-12-20 19:40:47'   WHERE supplierid = '7';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('7', '262140.00', '270', '1', 'اضافة فاتورة مردوات مشتريات', '2540', '261870', '2024-12-20 19:40:31', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','270','1','262140','270','261870','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2540;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:10:48";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:40:48", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-20 19:40:48', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2540');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:10:53";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:40:53", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 19:40:53', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:11:48";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:41:48", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:41:48', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:12:29";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 19:42:29", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-20 19:42:29', '2', '', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:12:30";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 19:42:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-20 19:42:30', '2', 'showallajax', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:12:35";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:42:35", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:42:35', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765a88ba1fd9
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6597,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 19:25:31', '06765a88ba1fd9', '6597', '0.00', '390', '10', '1', '400.00', '390', '0', '390', '1', '2024-12-20 19:42:35', '', '9', '0', 'سوما ستور 41', '1', '1', '3', '21', 'سوما ستور 41', '2' ,'0','','','','','-1','0','0','0','0','0','390','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '390', userid = '9' WHERE clientid = '6597';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6597','0.00','390','0','اضافة فاتورة مبيعات','150489', '390', '2024-12-20 19:42:35', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '390', '0', null, '0', null, null,'', '0','1','1','390','1','2024-12-20 19:25:31','0','0');
UPDATE client SET  inUse = 0 where clientid = 6597;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36048;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36290;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07001', '150489', '5', '15970', '2', '200', '400', '0', '', '1', '2024-12-20 19:42:35', '15970', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36048-1,36290-1,','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 142, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 549870;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15970, '2024-12-20', 390, 280, 280
                    , 280, 280, 280, 280.9
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 284, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280.9
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+284
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 390, 280, 280
                    , 280, 280, 280, 280.9
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 284, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280.9
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+284
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '9', storedetaildate = '2024-12-20 19:42:35' WHERE storedetailid = '15969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15970', '1', '2', '1', '150489', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '15', '9', '2024-12-20 19:42:35','0','0');
UPDATE client SET  delegateid = 21 where clientid = 6597;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 390, 280, 280
                    , 280, 280, 280, 280.9
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 284, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280.9
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+284
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6597, '2024-12-20', 390, 280, 280
                    , 280, 280, 280, 280.9
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 284, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280.9
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+284
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 390, 280, 280
                    , 280, 280, 280, 280.9, 280, 284)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+390, netSellCostBuyPrice = netSellCostBuyPrice+280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+280
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+280
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+280.9
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+280
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+284;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765a88ba1fd9 and sellbillId = 150489 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:12:36";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:42:36", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:42:36', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:12:42";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 19:42:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-20 19:42:42', '2', 'showallajax', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:12:47";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 19:42:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-20 19:42:47', '2', 'showallajax', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:12:54";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:42:54", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 19:42:54', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('H1681','','14','395','600', '600','600', '2024-12-20', '0', '77', '1', 'H1681', '0', '0', '0', '0', '0', '395','395','395','395','395','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','395','395','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16557, 1,'2024-12-20 19:42:57',77)
                ON DUPLICATE KEY UPDATE productid = 16557, edited = 1, sysdate = '2024-12-20 19:42:57', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16557', '1', '2024-12-20', '77', '0','1655701','600','600','600','395','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16557', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16557', '1', '0', '0', '16557', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:13:00";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-20 19:43:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-20 19:43:00', '2', 'showallajax', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:13:02";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:43:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:43:02', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765ac5c38b10', '2024-12-20 19:41:48', '20', '344960.00', '364510', '0', '0', '19550',  '19550', '0', '19550', '1', '2024-12-20 19:43:02', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07221', '14194', '5', '16279', '25', '335', '8375', '0', '', '2024-12-20 19:43:02', '16279','','','0','0','0','0','0',null,'335','8375','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:41:48', 1, 16279, 0, 0
                    , 335, 25, 0, 0, 77, '2024-12-20 19:43:02')
                ON DUPLICATE KEY UPDATE buyprice = 335,
                        buyQuantity =buyQuantity+25, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:43:02' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16279', '335', '25', '0', 'buyBillController.php', '32871', '', '0', '0');
UPDATE product SET  productBuyPrice = "335" WHERE productId = 16279 ;
UPDATE buybilldetail SET  quantitybefore = 56 WHERE buybilldetailid = 32871 ;
UPDATE product SET productName = '7221', productDescription = '', productCatId = '5', productBuyPrice = '335.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = '07221',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '335',lastbuyprice_withDiscount = '335',meanbuyprice = '335',meanbuyprice_withDiscount = '335' , productbuypricereal = '335.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='335',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='335',meanbuyprice_withTax='327',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='335'  WHERE productId = '16279';
UPDATE buybilldetail SET  lastbuyprice = 335 , meanbuyprice = 335, lastbuyprice_withDiscount = 335, meanbuyprice_withDiscount = 335
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 327, lastbuyprice_withDiscountAndTax = 335
                where buybilldetailid = 32871;
UPDATE productunit SET proUnitBuyPrice  = 335 * productnumber WHERE productid = 16279;
UPDATE storedetail SET  productquantity = '81', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '25', '0', '14194', 'اضافة فاتورة مشتريات', 'buyBillController.php', '56', '81', '77', '2024-12-20 19:41:48','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1666', '14194', '14', '16470', '10', '525', '5250', '0', '', '2024-12-20 19:43:02', '16470','','','0','0','0','0','0',null,'525','5250','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:41:48', 1, 16470, 0, 0
                    , 525, 10, 0, 0, 77, '2024-12-20 19:43:02')
                ON DUPLICATE KEY UPDATE buyprice = 525,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:43:02' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16470', '525', '10', '0', 'buyBillController.php', '32872', '', '0', '0');
UPDATE product SET  productBuyPrice = "525" WHERE productId = 16470 ;
UPDATE buybilldetail SET  quantitybefore = 1 WHERE buybilldetailid = 32872 ;
UPDATE product SET productName = 'H1666', productDescription = '', productCatId = '14', productBuyPrice = '525.00', productSellAllPrice = '650.00', productSellUnitPrice = '650.00', productSellHalfPrice = '650.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1666',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '525',lastbuyprice_withDiscount = '525',meanbuyprice = '525',meanbuyprice_withDiscount = '525' , productbuypricereal = '525.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='525',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='525',meanbuyprice_withTax='525',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='525'  WHERE productId = '16470';
UPDATE buybilldetail SET  lastbuyprice = 525 , meanbuyprice = 525, lastbuyprice_withDiscount = 525, meanbuyprice_withDiscount = 525
        , lastbuyprice_withTax = 525, meanbuyprice_withTax = 525, lastbuyprice_withDiscountAndTax = 525
                where buybilldetailid = 32872;
UPDATE productunit SET proUnitBuyPrice  = 525 * productnumber WHERE productid = 16470;
UPDATE storedetail SET  productquantity = '11', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16469';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16470', '1', '10', '0', '14194', 'اضافة فاتورة مشتريات', 'buyBillController.php', '1', '11', '77', '2024-12-20 19:41:48','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1681', '14194', '14', '16557', '15', '395', '5925', '0', '', '2024-12-20 19:43:02', '16557','','','0','0','0','0','0',null,'395','5925','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:41:48', 1, 16557, 0, 0
                    , 395, 15, 0, 0, 77, '2024-12-20 19:43:02')
                ON DUPLICATE KEY UPDATE buyprice = 395,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:43:02' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16557', '395', '15', '0', 'buyBillController.php', '32873', '', '0', '0');
UPDATE product SET  productBuyPrice = "395" WHERE productId = 16557 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32873 ;
UPDATE product SET productName = 'H1681', productDescription = '', productCatId = '14', productBuyPrice = '395.00', productSellAllPrice = '600.00', productSellUnitPrice = '600.00', productSellHalfPrice = '600.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1681',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '395',lastbuyprice_withDiscount = '395',meanbuyprice = '395',meanbuyprice_withDiscount = '395' , productbuypricereal = '395.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='395',meanbuyprice_withTax='395',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='395'  WHERE productId = '16557';
UPDATE buybilldetail SET  lastbuyprice = 395 , meanbuyprice = 395, lastbuyprice_withDiscount = 395, meanbuyprice_withDiscount = 395
        , lastbuyprice_withTax = 395, meanbuyprice_withTax = 395, lastbuyprice_withDiscountAndTax = 395
                where buybilldetailid = 32873;
UPDATE productunit SET proUnitBuyPrice  = 395 * productnumber WHERE productid = 16557;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16556';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16557', '1', '15', '0', '14194', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:41:48','0','0');
UPDATE supplier SET  suppliercurrentDebt = '364510',suppliercurrentDebtInCurrency= '364510' , userid = '77', supplierdate = '2024-12-20 19:43:02'   WHERE supplierid = '20';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('20', '344960.00', '19550', '0', 'اضافة فاتورة مشتريات', '14194', '364510', '2024-12-20 19:41:48', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','19550','1','344960','19550','364510','0');
update buybill set dailyentryid='0,' where buybillid=14194;
COMMIT;
UPDATE product SET overAllAveragePrice = 335 WHERE productId = 16279;UPDATE product SET overAllAveragePrice = 525 WHERE productId = 16470;UPDATE product SET overAllAveragePrice = 395 WHERE productId = 16557;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:13:03";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:43:03", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:43:03', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14194');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:14:19";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:44:19", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 19:44:19', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:14:35";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:44:35", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 19:44:35', '9', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248101
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9213,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '1135' , clientdate = '2024-12-20 19:44:35', userid = '9' WHERE clientid = '9213';
UPDATE client SET  inUse = 0 where clientid = 9213;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9213','1335.00','200','1','ايصال تحصيل (( قبض من عميل ))','248101', '1135', '2024-12-20 19:44:19', '9', 'clientPayedDeptController.php', '   ', '200', '0', null, '0', null, null,'', '-1','1','1','200','1','','3684','0');
UPDATE save SET  savecurrentvalue = '2685',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2485.00','200', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '248101', '2685', '2024-12-20 19:44:35', '9',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '200', '200', '2024-12-20', '9', '0', '0', '2024-12-20 19:44:35','اضافة ايصال سداد للعميل شيماء مخ برافو','1','0','0','0','248101','clientPayedDeptController.php?do=show&id=248101');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122353', '-1', '200', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '200', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122353', '-1', '200', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-200', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '9213', clientdebtchangebefore = '1335.000', clientdebtchangeamount = '200.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248101', clientdebtchangeafter = '1135.000', clientdebtchangedate = '2024-12-20 19:44:19', userid = '9', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '200.00',discount='', reciptid='0', dailyentryid = '122353',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='200',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248101';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248101 -clientdebtchangeId = 248101
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:14:36";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:44:36", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 19:44:36', '9', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:14:37";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:44:37", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 19:44:37', '9', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:20:06";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 19:50:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 19:50:06', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:22:02";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:52:02", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:52:02', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:23:43";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:53:43", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:53:43', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:23:56";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:53:56", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:53:56', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765af278616b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 19:53:43', '06765af278616b', '1', '0.00', '0', '0', '1', '370', '370', '-370', '0', '1', '2024-12-20 19:53:56', '', '9', '0', 'نقدي','1', '0', '5', '4', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-370','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16855', '0', '2024-12-20 19:53:56', '9', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '370', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 19:53:43','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('300.00', 'R3307', '16855', '1', '16120', '1', '370', '370', '0', '', '1', '0', '16120', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','370','370','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 300, lastbuyprice_withDiscountAndTax = 300
                where returnsellbilldetailid = 22046;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16120, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 370, 300, 300, 300
                    , 300, 300, 300, 0, 1, 0, 0, 300, 300)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+370, returnSellCostBuyPrice = returnSellCostBuyPrice+300, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+300
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+300, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+300
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+300
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+300
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+300
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+300
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 370, 300, 300, 300
                    , 300, 300, 300, 0, 0, 300, 300)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+370, returnSellCostBuyPrice = returnSellCostBuyPrice+300, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+300
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+300, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+300
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+300
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+300
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+300
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+300;
UPDATE storedetail SET  productquantity = '10', userid = '9', storedetaildate = '2024-12-20 19:53:56' WHERE storedetailid = '16119';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16120', '1', '1', '0', '16855', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '9', '10', '9', '2024-12-20 19:53:56','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2315',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2685','-370', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16855', '2315', '2024-12-20 19:53:56', '9',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 370, 300, 300, 300
                    , 300, 300, 300 ,0, 0, 300, 300)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+370, returnSellCostBuyPrice = returnSellCostBuyPrice+300, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+300
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+300, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+300
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+300
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+300
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+300
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+300;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 370, 300, 300, 300
                    , 300, 300, 300 ,0, 0, 300, 300)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+370, returnSellCostBuyPrice = returnSellCostBuyPrice+300, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+300
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+300, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+300
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+300
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+300
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+300
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+300;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -370, -300, -300
                    , -300, -300, -300, -300, -300, -300)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-370, netSellCostBuyPrice = netSellCostBuyPrice+-300
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-300
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-300
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-300
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-300
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-300
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-300
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-300;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765af278616b and sellbillId = 16855 and returnsellbillId = 16855
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:23:57";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:53:57", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:53:57', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:24:01";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 19:54:01", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 19:54:01', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:28:07";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:58:07", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:58:07', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('H1700','','14','535','650', '650','650', '2024-12-20', '0', '77', '1', 'H1700', '0', '0', '0', '0', '0', '535','535','535','535','535','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','535','535','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16558, 1,'2024-12-20 19:58:31',77)
                ON DUPLICATE KEY UPDATE productid = 16558, edited = 1, sysdate = '2024-12-20 19:58:31', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16558', '1', '2024-12-20', '77', '0','1655801','650','650','650','535','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16558', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16558', '1', '0', '0', '16558', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('H1701','','14','595','700', '700','700', '2024-12-20', '0', '77', '1', 'H1701', '0', '0', '0', '0', '0', '595','595','595','595','595','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','595','595','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16559, 1,'2024-12-20 19:59:13',77)
                ON DUPLICATE KEY UPDATE productid = 16559, edited = 1, sysdate = '2024-12-20 19:59:13', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16559', '1', '2024-12-20', '77', '0','1655901','700','700','700','595','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16559', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16559', '1', '0', '0', '16559', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('H1699','','14','465','550', '550','550', '2024-12-20', '0', '77', '1', 'H1699', '0', '0', '0', '0', '0', '465','465','465','465','465','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','465','465','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16560, 1,'2024-12-20 19:59:35',77)
                ON DUPLICATE KEY UPDATE productid = 16560, edited = 1, sysdate = '2024-12-20 19:59:35', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16560', '1', '2024-12-20', '77', '0','1656001','550','550','550','465','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16560', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16560', '1', '0', '0', '16560', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:29:49";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:59:49", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:59:49', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765b02f9f40b', '2024-12-20 19:58:07', '20', '364510.00', '405860', '0', '0', '41350',  '41350', '0', '41350', '1', '2024-12-20 19:59:49', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1700', '14195', '14', '16558', '10', '535', '5350', '0', '', '2024-12-20 19:59:49', '16558','','','0','0','0','0','0',null,'535','5350','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:58:07', 1, 16558, 0, 0
                    , 535, 10, 0, 0, 77, '2024-12-20 19:59:49')
                ON DUPLICATE KEY UPDATE buyprice = 535,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:59:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16558', '535', '10', '0', 'buyBillController.php', '32874', '', '0', '0');
UPDATE product SET  productBuyPrice = "535" WHERE productId = 16558 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32874 ;
UPDATE product SET productName = 'H1700', productDescription = '', productCatId = '14', productBuyPrice = '535.00', productSellAllPrice = '650.00', productSellUnitPrice = '650.00', productSellHalfPrice = '650.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1700',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '535',lastbuyprice_withDiscount = '535',meanbuyprice = '535',meanbuyprice_withDiscount = '535' , productbuypricereal = '535.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='535',meanbuyprice_withTax='535',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='535'  WHERE productId = '16558';
UPDATE buybilldetail SET  lastbuyprice = 535 , meanbuyprice = 535, lastbuyprice_withDiscount = 535, meanbuyprice_withDiscount = 535
        , lastbuyprice_withTax = 535, meanbuyprice_withTax = 535, lastbuyprice_withDiscountAndTax = 535
                where buybilldetailid = 32874;
UPDATE productunit SET proUnitBuyPrice  = 535 * productnumber WHERE productid = 16558;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16557';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16558', '1', '10', '0', '14195', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-20 19:58:07','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1701', '14195', '14', '16559', '15', '595', '8925', '0', '', '2024-12-20 19:59:49', '16559','','','0','0','0','0','0',null,'595','8925','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:58:07', 1, 16559, 0, 0
                    , 595, 15, 0, 0, 77, '2024-12-20 19:59:49')
                ON DUPLICATE KEY UPDATE buyprice = 595,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:59:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16559', '595', '15', '0', 'buyBillController.php', '32875', '', '0', '0');
UPDATE product SET  productBuyPrice = "595" WHERE productId = 16559 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32875 ;
UPDATE product SET productName = 'H1701', productDescription = '', productCatId = '14', productBuyPrice = '595.00', productSellAllPrice = '700.00', productSellUnitPrice = '700.00', productSellHalfPrice = '700.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1701',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '595',lastbuyprice_withDiscount = '595',meanbuyprice = '595',meanbuyprice_withDiscount = '595' , productbuypricereal = '595.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='595',meanbuyprice_withTax='595',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='595'  WHERE productId = '16559';
UPDATE buybilldetail SET  lastbuyprice = 595 , meanbuyprice = 595, lastbuyprice_withDiscount = 595, meanbuyprice_withDiscount = 595
        , lastbuyprice_withTax = 595, meanbuyprice_withTax = 595, lastbuyprice_withDiscountAndTax = 595
                where buybilldetailid = 32875;
UPDATE productunit SET proUnitBuyPrice  = 595 * productnumber WHERE productid = 16559;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16558';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16559', '1', '15', '0', '14195', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:58:07','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1699', '14195', '14', '16560', '15', '465', '6975', '0', '', '2024-12-20 19:59:49', '16560','','','0','0','0','0','0',null,'465','6975','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:58:07', 1, 16560, 0, 0
                    , 465, 15, 0, 0, 77, '2024-12-20 19:59:49')
                ON DUPLICATE KEY UPDATE buyprice = 465,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:59:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16560', '465', '15', '0', 'buyBillController.php', '32876', '', '0', '0');
UPDATE product SET  productBuyPrice = "465" WHERE productId = 16560 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32876 ;
UPDATE product SET productName = 'H1699', productDescription = '', productCatId = '14', productBuyPrice = '465.00', productSellAllPrice = '550.00', productSellUnitPrice = '550.00', productSellHalfPrice = '550.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1699',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '465',lastbuyprice_withDiscount = '465',meanbuyprice = '465',meanbuyprice_withDiscount = '465' , productbuypricereal = '465.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='465',meanbuyprice_withTax='465',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='465'  WHERE productId = '16560';
UPDATE buybilldetail SET  lastbuyprice = 465 , meanbuyprice = 465, lastbuyprice_withDiscount = 465, meanbuyprice_withDiscount = 465
        , lastbuyprice_withTax = 465, meanbuyprice_withTax = 465, lastbuyprice_withDiscountAndTax = 465
                where buybilldetailid = 32876;
UPDATE productunit SET proUnitBuyPrice  = 465 * productnumber WHERE productid = 16560;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16559';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16560', '1', '15', '0', '14195', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:58:07','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07221', '14195', '5', '16279', '60', '335', '20100', '0', '', '2024-12-20 19:59:49', '16279','','','0','0','0','0','0',null,'335','20100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:58:07', 1, 16279, 0, 0
                    , 335, 60, 0, 0, 77, '2024-12-20 19:59:49')
                ON DUPLICATE KEY UPDATE buyprice = 335,
                        buyQuantity =buyQuantity+60, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 19:59:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16279', '335', '60', '0', 'buyBillController.php', '32877', '', '0', '0');
UPDATE product SET  productBuyPrice = "335" WHERE productId = 16279 ;
UPDATE buybilldetail SET  quantitybefore = 81 WHERE buybilldetailid = 32877 ;
UPDATE product SET productName = '7221', productDescription = '', productCatId = '5', productBuyPrice = '335.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = '07221',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '335',lastbuyprice_withDiscount = '335',meanbuyprice = '335',meanbuyprice_withDiscount = '335' , productbuypricereal = '335.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='335',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='335',meanbuyprice_withTax='330',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='335'  WHERE productId = '16279';
UPDATE buybilldetail SET  lastbuyprice = 335 , meanbuyprice = 335, lastbuyprice_withDiscount = 335, meanbuyprice_withDiscount = 335
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 335
                where buybilldetailid = 32877;
UPDATE productunit SET proUnitBuyPrice  = 335 * productnumber WHERE productid = 16279;
UPDATE storedetail SET  productquantity = '141', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '60', '0', '14195', 'اضافة فاتورة مشتريات', 'buyBillController.php', '81', '141', '77', '2024-12-20 19:58:07','0','0');
UPDATE supplier SET  suppliercurrentDebt = '405860',suppliercurrentDebtInCurrency= '405860' , userid = '77', supplierdate = '2024-12-20 19:59:49'   WHERE supplierid = '20';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('20', '364510.00', '41350', '0', 'اضافة فاتورة مشتريات', '14195', '405860', '2024-12-20 19:58:07', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','41350','1','364510','41350','405860','0');
update buybill set dailyentryid='0,' where buybillid=14195;
COMMIT;
UPDATE product SET overAllAveragePrice = 335 WHERE productId = 16279;UPDATE product SET overAllAveragePrice = 535 WHERE productId = 16558;UPDATE product SET overAllAveragePrice = 595 WHERE productId = 16559;UPDATE product SET overAllAveragePrice = 465 WHERE productId = 16560;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:29:50";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 19:59:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 19:59:50', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14195');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:31:13";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:01:13", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:01:13', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:31:18";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:01:18", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 20:01:18', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:31:24";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:01:24", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-20 20:01:24', '77', 'oneSupplier', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:31:36";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:01:36", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:01:36', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:32:25";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:02:25", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:02:25', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765b10052aaf', '2024-12-20 20:01:36', '160', '138330.00', '159630', '0', '0', '21300',  '21300', '0', '21300', '1', '2024-12-20 20:02:25', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07325', '14196', '5', '16517', '10', '385', '3850', '0', '', '2024-12-20 20:02:25', '16517','','','0','0','0','0','0',null,'385','3850','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:01:36', 1, 16517, 0, 0
                    , 385, 10, 0, 0, 77, '2024-12-20 20:02:25')
                ON DUPLICATE KEY UPDATE buyprice = 385,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:02:25' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16517', '385', '10', '0', 'buyBillController.php', '32878', '', '0', '0');
UPDATE product SET  productBuyPrice = "385" WHERE productId = 16517 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32878 ;
UPDATE product SET productName = '7325', productDescription = '', productCatId = '5', productBuyPrice = '385.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2024-12-19', conditions = '0', userId = '77', limitamount = '1', parcode = '07325',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '385',lastbuyprice_withDiscount = '385',meanbuyprice = '385',meanbuyprice_withDiscount = '385' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='250',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='385',meanbuyprice_withTax='385',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='385'  WHERE productId = '16517';
UPDATE buybilldetail SET  lastbuyprice = 385 , meanbuyprice = 385, lastbuyprice_withDiscount = 385, meanbuyprice_withDiscount = 385
        , lastbuyprice_withTax = 385, meanbuyprice_withTax = 385, lastbuyprice_withDiscountAndTax = 385
                where buybilldetailid = 32878;
UPDATE productunit SET proUnitBuyPrice  = 385 * productnumber WHERE productid = 16517;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16516';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16517', '1', '10', '0', '14196', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-20 20:01:36','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07361', '14196', '5', '16521', '10', '575', '5750', '0', '', '2024-12-20 20:02:25', '16521','','','0','0','0','0','0',null,'575','5750','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:01:36', 1, 16521, 0, 0
                    , 575, 10, 0, 0, 77, '2024-12-20 20:02:25')
                ON DUPLICATE KEY UPDATE buyprice = 575,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:02:25' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16521', '575', '10', '0', 'buyBillController.php', '32879', '', '0', '0');
UPDATE product SET  productBuyPrice = "575" WHERE productId = 16521 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32879 ;
UPDATE product SET productName = '7361', productDescription = '', productCatId = '5', productBuyPrice = '575.00', productSellAllPrice = '650.00', productSellUnitPrice = '650.00', productSellHalfPrice = '650.00', productDate = '2024-12-19', conditions = '0', userId = '77', limitamount = '1', parcode = '07361',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '575',lastbuyprice_withDiscount = '575',meanbuyprice = '575',meanbuyprice_withDiscount = '575' , productbuypricereal = '575.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='575',meanbuyprice_withTax='575',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='575'  WHERE productId = '16521';
UPDATE buybilldetail SET  lastbuyprice = 575 , meanbuyprice = 575, lastbuyprice_withDiscount = 575, meanbuyprice_withDiscount = 575
        , lastbuyprice_withTax = 575, meanbuyprice_withTax = 575, lastbuyprice_withDiscountAndTax = 575
                where buybilldetailid = 32879;
UPDATE productunit SET proUnitBuyPrice  = 575 * productnumber WHERE productid = 16521;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16520';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16521', '1', '10', '0', '14196', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-20 20:01:36','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07324', '14196', '5', '16522', '10', '595', '5950', '0', '', '2024-12-20 20:02:25', '16522','','','0','0','0','0','0',null,'595','5950','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:01:36', 1, 16522, 0, 0
                    , 595, 10, 0, 0, 77, '2024-12-20 20:02:25')
                ON DUPLICATE KEY UPDATE buyprice = 595,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:02:25' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16522', '595', '10', '0', 'buyBillController.php', '32880', '', '0', '0');
UPDATE product SET  productBuyPrice = "595" WHERE productId = 16522 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32880 ;
UPDATE product SET productName = '7324', productDescription = '', productCatId = '5', productBuyPrice = '595.00', productSellAllPrice = '700.00', productSellUnitPrice = '700.00', productSellHalfPrice = '700.00', productDate = '2024-12-19', conditions = '0', userId = '77', limitamount = '1', parcode = '07324',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '595',lastbuyprice_withDiscount = '595',meanbuyprice = '595',meanbuyprice_withDiscount = '595' , productbuypricereal = '595.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='595',meanbuyprice_withTax='595',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='595'  WHERE productId = '16522';
UPDATE buybilldetail SET  lastbuyprice = 595 , meanbuyprice = 595, lastbuyprice_withDiscount = 595, meanbuyprice_withDiscount = 595
        , lastbuyprice_withTax = 595, meanbuyprice_withTax = 595, lastbuyprice_withDiscountAndTax = 595
                where buybilldetailid = 32880;
UPDATE productunit SET proUnitBuyPrice  = 595 * productnumber WHERE productid = 16522;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16521';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16522', '1', '10', '0', '14196', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-20 20:01:36','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07327', '14196', '5', '16491', '10', '575', '5750', '0', '', '2024-12-20 20:02:25', '16491','','','0','0','0','0','0',null,'575','5750','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:01:36', 1, 16491, 0, 0
                    , 575, 10, 0, 0, 77, '2024-12-20 20:02:25')
                ON DUPLICATE KEY UPDATE buyprice = 575,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:02:25' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16491', '575', '10', '0', 'buyBillController.php', '32881', '', '0', '0');
UPDATE product SET  productBuyPrice = "575" WHERE productId = 16491 ;
UPDATE buybilldetail SET  quantitybefore = 10 WHERE buybilldetailid = 32881 ;
UPDATE product SET productName = '7327', productDescription = '', productCatId = '5', productBuyPrice = '575.00', productSellAllPrice = '670.00', productSellUnitPrice = '670.00', productSellHalfPrice = '670.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07327',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '575',lastbuyprice_withDiscount = '575',meanbuyprice = '575',meanbuyprice_withDiscount = '575' , productbuypricereal = '575.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='575',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='575',meanbuyprice_withTax='575',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='575'  WHERE productId = '16491';
UPDATE buybilldetail SET  lastbuyprice = 575 , meanbuyprice = 575, lastbuyprice_withDiscount = 575, meanbuyprice_withDiscount = 575
        , lastbuyprice_withTax = 575, meanbuyprice_withTax = 575, lastbuyprice_withDiscountAndTax = 575
                where buybilldetailid = 32881;
UPDATE productunit SET proUnitBuyPrice  = 575 * productnumber WHERE productid = 16491;
UPDATE storedetail SET  productquantity = '20', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16490';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16491', '1', '10', '0', '14196', 'اضافة فاتورة مشتريات', 'buyBillController.php', '10', '20', '77', '2024-12-20 20:01:36','0','0');
UPDATE supplier SET  suppliercurrentDebt = '159630',suppliercurrentDebtInCurrency= '159630' , userid = '77', supplierdate = '2024-12-20 20:02:25'   WHERE supplierid = '160';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('160', '138330.00', '21300', '0', 'اضافة فاتورة مشتريات', '14196', '159630', '2024-12-20 20:01:36', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','21300','1','138330','21300','159630','0');
update buybill set dailyentryid='0,' where buybillid=14196;
COMMIT;
UPDATE product SET overAllAveragePrice = 575 WHERE productId = 16491;UPDATE product SET overAllAveragePrice = 304 WHERE productId = 16517;UPDATE product SET overAllAveragePrice = 575 WHERE productId = 16521;UPDATE product SET overAllAveragePrice = 595 WHERE productId = 16522;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:32:26";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:02:26", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:02:26', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14196');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:33:35";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:03:35", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:03:35', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765af394807e
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 19:54:01', '06765af394807e', '1', '0.00', '0', '0', '1', '1080.00', '1080', '1080', '0', '1', '2024-12-20 20:03:35', '', '9', '0', 'نقدي', '1', '0', '3', '25', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','1080','0','','0','0','1080','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150490', '0', '2024-12-20 20:03:35', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1080', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 19:54:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36373;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('400','R3341', '150490', '1', '16440', '1', '470', '470', '0', '', '1', '2024-12-20 20:03:35', '16440', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36373-1,','1','1','0','0','470','470','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 549871;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16440, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 470, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '55', userid = '9', storedetaildate = '2024-12-20 20:03:35' WHERE storedetailid = '16439';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16440', '1', '1', '1', '150490', 'اضافة فاتورة مبيعات', 'sellbillController.php', '56', '55', '9', '2024-12-20 20:03:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36085;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('525','R3330', '150490', '1', '16365', '1', '610', '610', '0', '', '1', '2024-12-20 20:03:35', '16365', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36085-1,','1','1','0','0','610','610','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 525.00 , meanbuyprice = 525.00, lastbuyprice_withDiscount = 525.00, meanbuyprice_withDiscount = 525.00
        , lastbuyprice_withTax = 525, meanbuyprice_withTax = 525, lastbuyprice_withDiscountAndTax = 525
                where sellbilldetailid = 549872;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16365, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 610, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '9', storedetaildate = '2024-12-20 20:03:35' WHERE storedetailid = '16364';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16365', '1', '1', '1', '150490', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '9', '2024-12-20 20:03:35','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '3395',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2315','1080', '0', '1', 'اضافة فاتورة مبيعات', '150490', '3395', '2024-12-20 20:03:35', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 25 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 1080, 925, 925
                    , 925, 925, 925, 925
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,925, 925, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1080, sellCostBuyPrice =sellCostBuyPrice+925
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+925, sellCostMeanBuyPrice = sellCostMeanBuyPrice+925
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+925, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+925
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+925
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+925
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+925
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1080, 925, 925
                    , 925, 925, 925, 925
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,925, 925, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1080, sellCostBuyPrice =sellCostBuyPrice+925
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+925, sellCostMeanBuyPrice = sellCostMeanBuyPrice+925
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+925, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+925
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+925
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+925
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+925
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1080, 925, 925
                    , 925, 925, 925, 925, 925, 925)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1080, netSellCostBuyPrice = netSellCostBuyPrice+925
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+925
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+925
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+925
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+925
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+925
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+925
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+925;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765af394807e and sellbillId = 150490 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:33:36";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:03:36", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:03:36', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:34:11";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:04:11", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:04:11', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:34:35";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:04:35", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:04:35', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765b19b3e038', '2024-12-20 20:04:11', '235', '40855.00', '41955', '0', '0', '1100',  '1100', '0', '1100', '1', '2024-12-20 20:04:35', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('R3332', '14197', '1', '16399', '10', '110', '1100', '0', '', '2024-12-20 20:04:35', '16399','','','0','0','0','0','0',null,'110','1100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:04:11', 1, 16399, 0, 0
                    , 110, 10, 0, 0, 77, '2024-12-20 20:04:35')
                ON DUPLICATE KEY UPDATE buyprice = 110,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:04:35' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16399', '110', '10', '0', 'buyBillController.php', '32882', '', '0', '0');
UPDATE product SET  productBuyPrice = "110" WHERE productId = 16399 ;
UPDATE buybilldetail SET  quantitybefore = 7 WHERE buybilldetailid = 32882 ;
UPDATE product SET productName = 'R3332', productDescription = '', productCatId = '1', productBuyPrice = '110.00', productSellAllPrice = '160.00', productSellUnitPrice = '160.00', productSellHalfPrice = '160.00', productDate = '2024-12-11', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3332',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '110',lastbuyprice_withDiscount = '110',meanbuyprice = '110',meanbuyprice_withDiscount = '110' , productbuypricereal = '110.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='110',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='110',meanbuyprice_withTax='110',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='110'  WHERE productId = '16399';
UPDATE buybilldetail SET  lastbuyprice = 110 , meanbuyprice = 110, lastbuyprice_withDiscount = 110, meanbuyprice_withDiscount = 110
        , lastbuyprice_withTax = 110, meanbuyprice_withTax = 110, lastbuyprice_withDiscountAndTax = 110
                where buybilldetailid = 32882;
UPDATE productunit SET proUnitBuyPrice  = 110 * productnumber WHERE productid = 16399;
UPDATE storedetail SET  productquantity = '17', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16398';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16399', '1', '10', '0', '14197', 'اضافة فاتورة مشتريات', 'buyBillController.php', '7', '17', '77', '2024-12-20 20:04:11','0','0');
UPDATE supplier SET  suppliercurrentDebt = '41955',suppliercurrentDebtInCurrency= '41955' , userid = '77', supplierdate = '2024-12-20 20:04:35'   WHERE supplierid = '235';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('235', '40855.00', '1100', '0', 'اضافة فاتورة مشتريات', '14197', '41955', '2024-12-20 20:04:11', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','1100','1','40855','1100','41955','0');
update buybill set dailyentryid='0,' where buybillid=14197;
COMMIT;
UPDATE product SET overAllAveragePrice = 110 WHERE productId = 16399;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:34:35";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:04:35", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:04:35', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14197');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:34:40";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:04:40", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:04:40', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765b1789a9d1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 20:03:36', '06765b1789a9d1', '1', '0.00', '0', '0', '1', '520.00', '520', '520', '0', '1', '2024-12-20 20:04:40', '', '9', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','520','0','','0','0','520','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150491', '0', '2024-12-20 20:04:40', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '520', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 20:03:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36461;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('410','H1663', '150491', '14', '16471', '1', '520', '520', '0', '', '1', '2024-12-20 20:04:40', '16471', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36461-1,','1','1','0','0','520','520','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
        , lastbuyprice_withTax = 410, meanbuyprice_withTax = 410, lastbuyprice_withDiscountAndTax = 410
                where sellbilldetailid = 549873;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16471, '2024-12-20', 520, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 520, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '23', userid = '9', storedetaildate = '2024-12-20 20:04:40' WHERE storedetailid = '16470';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16471', '1', '1', '1', '150491', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '9', '2024-12-20 20:04:40','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '3915',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('3395','520', '0', '1', 'اضافة فاتورة مبيعات', '150491', '3915', '2024-12-20 20:04:40', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 520, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 520, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 520, 410, 410
                    , 410, 410, 410, 410, 410, 410)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+520, netSellCostBuyPrice = netSellCostBuyPrice+410
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+410
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+410
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+410
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+410
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+410
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+410
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+410;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765b1789a9d1 and sellbillId = 150491 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:34:41";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:04:41", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:04:41', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:35:31";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:05:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:05:31', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765b1b95e825
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 20:04:41', '06765b1b95e825', '1', '0.00', '0', '0', '1', '210.00', '210', '210', '0', '1', '2024-12-20 20:05:31', '', '9', '0', 'نقدي', '1', '0', '3', '94', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','210','0','','0','0','210','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150492', '0', '2024-12-20 20:05:31', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '210', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 20:04:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 22300;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','0K393', '150492', '7', '9386', '1', '210', '210', '0', '', '1', '2024-12-20 20:05:31', '9386', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','22300-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 272.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 272.00
        
                where sellbilldetailid = 549874;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9386, '2024-12-20', 210, 250, 250
                    , 272, 250, 272, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+272
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+272
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 250, 250
                    , 272, 250, 272, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+272
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+272
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-14', userid = '9', storedetaildate = '2024-12-20 20:05:31' WHERE storedetailid = '9385';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9386', '1', '1', '1', '150492', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-13', '-14', '9', '2024-12-20 20:05:31','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '4125',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('3915','210', '0', '1', 'اضافة فاتورة مبيعات', '150492', '4125', '2024-12-20 20:05:31', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 94 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 210, 250, 250
                    , 272, 250, 272, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+272
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+272
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 210, 250, 250
                    , 272, 250, 272, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+272
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+272
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 210, 250, 250
                    , 272, 250, 272, 250, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+210, netSellCostBuyPrice = netSellCostBuyPrice+250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+272
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+272
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+250
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765b1b95e825 and sellbillId = 150492 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:35:31";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:05:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:05:31', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:37:06";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:07:06", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:07:06', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:37:37";
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:37:37";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:37:51";
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:37:52";
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7362','','5','155','210', '210','210', '2024-12-20', '0', '77', '1', '07362', '0', '0', '0', '0', '0', '155','155','155','155','155','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','155','155','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16561, 1,'2024-12-20 20:08:28',77)
                ON DUPLICATE KEY UPDATE productid = 16561, edited = 1, sysdate = '2024-12-20 20:08:28', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16561', '1', '2024-12-20', '77', '0','1656101','210','210','210','155','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16561', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16561', '1', '0', '0', '16561', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('R3359','','1','115','165', '165','165', '2024-12-20', '0', '77', '1', 'R3359', '0', '0', '0', '0', '0', '115','115','115','115','115','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','115','115','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16562, 1,'2024-12-20 20:08:59',77)
                ON DUPLICATE KEY UPDATE productid = 16562, edited = 1, sysdate = '2024-12-20 20:08:59', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16562', '1', '2024-12-20', '77', '0','1656201','165','165','165','115','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16562', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16562', '1', '0', '0', '16562', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:39:15";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:09:15", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:09:15', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765b24abba45', '2024-12-20 20:07:06', '102', '200760.00', '216735', '0', '0', '15975',  '15975', '0', '15975', '1', '2024-12-20 20:09:15', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07296', '14198', '5', '16435', '40', '150', '6000', '0', '', '2024-12-20 20:09:15', '16435','','','0','0','0','0','0',null,'150','6000','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:07:06', 1, 16435, 0, 0
                    , 150, 40, 0, 0, 77, '2024-12-20 20:09:15')
                ON DUPLICATE KEY UPDATE buyprice = 150,
                        buyQuantity =buyQuantity+40, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:09:15' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16435', '150', '40', '0', 'buyBillController.php', '32883', '', '0', '0');
UPDATE product SET  productBuyPrice = "150" WHERE productId = 16435 ;
UPDATE buybilldetail SET  quantitybefore = 9 WHERE buybilldetailid = 32883 ;
UPDATE product SET productName = '7296', productDescription = '', productCatId = '5', productBuyPrice = '150.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-13', conditions = '0', userId = '77', limitamount = '1', parcode = '07296',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '150',lastbuyprice_withDiscount = '150',meanbuyprice = '150',meanbuyprice_withDiscount = '150' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='150',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='150',meanbuyprice_withTax='150',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='150'  WHERE productId = '16435';
UPDATE buybilldetail SET  lastbuyprice = 150 , meanbuyprice = 150, lastbuyprice_withDiscount = 150, meanbuyprice_withDiscount = 150
        , lastbuyprice_withTax = 150, meanbuyprice_withTax = 150, lastbuyprice_withDiscountAndTax = 150
                where buybilldetailid = 32883;
UPDATE productunit SET proUnitBuyPrice  = 150 * productnumber WHERE productid = 16435;
UPDATE storedetail SET  productquantity = '49', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16434';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16435', '1', '40', '0', '14198', 'اضافة فاتورة مشتريات', 'buyBillController.php', '9', '49', '77', '2024-12-20 20:07:06','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07118', '14198', '5', '16125', '15', '155', '2325', '0', '', '2024-12-20 20:09:15', '16125','','','0','0','0','0','0',null,'155','2325','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:07:06', 1, 16125, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-20 20:09:15')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:09:15' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16125', '155', '15', '0', 'buyBillController.php', '32884', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 16125 ;
UPDATE buybilldetail SET  quantitybefore = 35 WHERE buybilldetailid = 32884 ;
UPDATE product SET productName = '7118', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-11-26', conditions = '0', userId = '77', limitamount = '1', parcode = '07118',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '155.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='155',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '16125';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32884;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 16125;
UPDATE storedetail SET  productquantity = '50', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16124';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16125', '1', '15', '0', '14198', 'اضافة فاتورة مشتريات', 'buyBillController.php', '35', '50', '77', '2024-12-20 20:07:06','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07362', '14198', '5', '16561', '15', '155', '2325', '0', '', '2024-12-20 20:09:15', '16561','','','0','0','0','0','0',null,'155','2325','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:07:06', 1, 16561, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-20 20:09:15')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:09:15' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16561', '155', '15', '0', 'buyBillController.php', '32885', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 16561 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32885 ;
UPDATE product SET productName = '7362', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '210.00', productSellUnitPrice = '210.00', productSellHalfPrice = '210.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07362',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '155.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '16561';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32885;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 16561;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16560';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16561', '1', '15', '0', '14198', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 20:07:06','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06861', '14198', '5', '15635', '15', '240', '3600', '0', '', '2024-12-20 20:09:15', '15635','','','0','0','0','0','0',null,'240','3600','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:07:06', 1, 15635, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-20 20:09:15')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:09:15' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15635', '240', '15', '0', 'buyBillController.php', '32886', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 15635 ;
UPDATE buybilldetail SET  quantitybefore = 6 WHERE buybilldetailid = 32886 ;
UPDATE product SET productName = '6861', productDescription = '', productCatId = '5', productBuyPrice = '240.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-10-24', conditions = '0', userId = '77', limitamount = '0', parcode = '06861',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '240',lastbuyprice_withDiscount = '240',meanbuyprice = '240',meanbuyprice_withDiscount = '240' , productbuypricereal = '240.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '25.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='236.67',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',barcodeInTax='',productNameE='',partNumber='0',vehicleType='-1',company='-1',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='240',meanbuyprice_withTax='240',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='240'  WHERE productId = '15635';
UPDATE buybilldetail SET  lastbuyprice = 240 , meanbuyprice = 240, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 240
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32886;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 15635;
UPDATE storedetail SET  productquantity = '21', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '15634';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15635', '1', '15', '0', '14198', 'اضافة فاتورة مشتريات', 'buyBillController.php', '6', '21', '77', '2024-12-20 20:07:06','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('R3359', '14198', '1', '16562', '15', '115', '1725', '0', '', '2024-12-20 20:09:15', '16562','','','0','0','0','0','0',null,'115','1725','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:07:06', 1, 16562, 0, 0
                    , 115, 15, 0, 0, 77, '2024-12-20 20:09:15')
                ON DUPLICATE KEY UPDATE buyprice = 115,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:09:15' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16562', '115', '15', '0', 'buyBillController.php', '32887', '', '0', '0');
UPDATE product SET  productBuyPrice = "115" WHERE productId = 16562 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32887 ;
UPDATE product SET productName = 'R3359', productDescription = '', productCatId = '1', productBuyPrice = '115.00', productSellAllPrice = '165.00', productSellUnitPrice = '165.00', productSellHalfPrice = '165.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3359',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '115',lastbuyprice_withDiscount = '115',meanbuyprice = '115',meanbuyprice_withDiscount = '115' , productbuypricereal = '115.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='115',meanbuyprice_withTax='115',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='115'  WHERE productId = '16562';
UPDATE buybilldetail SET  lastbuyprice = 115 , meanbuyprice = 115, lastbuyprice_withDiscount = 115, meanbuyprice_withDiscount = 115
        , lastbuyprice_withTax = 115, meanbuyprice_withTax = 115, lastbuyprice_withDiscountAndTax = 115
                where buybilldetailid = 32887;
UPDATE productunit SET proUnitBuyPrice  = 115 * productnumber WHERE productid = 16562;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16561';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16562', '1', '15', '0', '14198', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 20:07:06','0','0');
UPDATE supplier SET  suppliercurrentDebt = '216735',suppliercurrentDebtInCurrency= '216735' , userid = '77', supplierdate = '2024-12-20 20:09:15'   WHERE supplierid = '102';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('102', '200760.00', '15975', '0', 'اضافة فاتورة مشتريات', '14198', '216735', '2024-12-20 20:07:06', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','15975','1','200760','15975','216735','0');
update buybill set dailyentryid='0,' where buybillid=14198;
COMMIT;
UPDATE product SET overAllAveragePrice = 236.92 WHERE productId = 15635;UPDATE product SET overAllAveragePrice = 155 WHERE productId = 16125;UPDATE product SET overAllAveragePrice = 150 WHERE productId = 16435;UPDATE product SET overAllAveragePrice = 155 WHERE productId = 16561;UPDATE product SET overAllAveragePrice = 115 WHERE productId = 16562;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:39:16";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:09:16", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:09:16', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14198');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:39:49";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:09:49", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:09:49', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE productunit SET unitid = '1', productid = '16378', productnumber = '1.00', productunitdate = '2024-12-10', userid = '77', conditions = '0',proUnitParcode='1637801',proUnitSellAllPrice='220',proUnitSellHalfPrice='220',proUnitSellUnitPrice ='220',proUnitBuyPrice='165',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16378';
UPDATE product SET productName = '7269', productDescription = '', productCatId = '5', productBuyPrice = '160', productSellAllPrice = '220', productSellUnitPrice = '220', productSellHalfPrice = '220', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07269',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '165.00',lastbuyprice_withDiscount = '165',meanbuyprice = '162',meanbuyprice_withDiscount = '162' , productbuypricereal = '160' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='161.67',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='165',meanbuyprice_withTax='162',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='165'  WHERE productId = '16378';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:40:20";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:10:20", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:10:20', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765b2edde2e8', '2024-12-20 20:09:49', '102', '216735.00', '219135', '0', '0', '2400',  '2400', '0', '2400', '1', '2024-12-20 20:10:20', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07269', '14199', '5', '16378', '15', '160', '2400', '0', '', '2024-12-20 20:10:20', '16378','','','0','0','0','0','0',null,'160','2400','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:09:49', 1, 16378, 0, 0
                    , 160, 15, 0, 0, 77, '2024-12-20 20:10:20')
                ON DUPLICATE KEY UPDATE buyprice = 160,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:10:20' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16378', '160', '15', '0', 'buyBillController.php', '32888', '', '0', '0');
UPDATE product SET  productBuyPrice = "160" WHERE productId = 16378 ;
UPDATE buybilldetail SET  quantitybefore = 36 WHERE buybilldetailid = 32888 ;
UPDATE product SET productName = '7269', productDescription = '', productCatId = '5', productBuyPrice = '160.00', productSellAllPrice = '220.00', productSellUnitPrice = '220.00', productSellHalfPrice = '220.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07269',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '160',lastbuyprice_withDiscount = '160',meanbuyprice = '161',meanbuyprice_withDiscount = '161' , productbuypricereal = '160.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='161.67',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='160',meanbuyprice_withTax='161',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='160'  WHERE productId = '16378';
UPDATE buybilldetail SET  lastbuyprice = 160 , meanbuyprice = 161, lastbuyprice_withDiscount = 160, meanbuyprice_withDiscount = 161
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 161, lastbuyprice_withDiscountAndTax = 160
                where buybilldetailid = 32888;
UPDATE productunit SET proUnitBuyPrice  = 160 * productnumber WHERE productid = 16378;
UPDATE storedetail SET  productquantity = '51', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16377';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16378', '1', '15', '0', '14199', 'اضافة فاتورة مشتريات', 'buyBillController.php', '36', '51', '77', '2024-12-20 20:09:49','0','0');
UPDATE supplier SET  suppliercurrentDebt = '219135',suppliercurrentDebtInCurrency= '219135' , userid = '77', supplierdate = '2024-12-20 20:10:20'   WHERE supplierid = '102';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('102', '216735.00', '2400', '0', 'اضافة فاتورة مشتريات', '14199', '219135', '2024-12-20 20:09:49', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','2400','1','216735','2400','219135','0');
update buybill set dailyentryid='0,' where buybillid=14199;
COMMIT;
UPDATE product SET overAllAveragePrice = 161.25 WHERE productId = 16378;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:40:20";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:10:20", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:10:20', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14199');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:40:37";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:10:37", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:10:37', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE productunit SET unitid = '1', productid = '16077', productnumber = '1.00', productunitdate = '2024-11-22', userid = '77', conditions = '0',proUnitParcode='1607701',proUnitSellAllPrice='350',proUnitSellHalfPrice='350',proUnitSellUnitPrice ='350',proUnitBuyPrice='285',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16077';
UPDATE product SET productName = 'R3303', productDescription = '', productCatId = '1', productBuyPrice = '295', productSellAllPrice = '350', productSellUnitPrice = '350', productSellHalfPrice = '350', productDate = '2024-11-22', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3303',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '285.00',lastbuyprice_withDiscount = '285',meanbuyprice = '290',meanbuyprice_withDiscount = '290' , productbuypricereal = '285' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='285',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='285',meanbuyprice_withTax='285',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='285'  WHERE productId = '16077';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:41:41";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:11:41", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:11:41', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765b31ddd03c', '2024-12-20 20:10:37', '49', '34320.00', '43170', '0', '0', '8850',  '8850', '0', '8850', '1', '2024-12-20 20:11:41', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('R3303', '14200', '1', '16077', '30', '295', '8850', '0', '', '2024-12-20 20:11:41', '16077','','','0','0','0','0','0',null,'295','8850','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:10:37', 1, 16077, 0, 0
                    , 295, 30, 0, 0, 77, '2024-12-20 20:11:41')
                ON DUPLICATE KEY UPDATE buyprice = 295,
                        buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:11:41' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16077', '295', '30', '0', 'buyBillController.php', '32889', '', '0', '0');
UPDATE product SET  productBuyPrice = "295" WHERE productId = 16077 ;
UPDATE buybilldetail SET  quantitybefore = 4 WHERE buybilldetailid = 32889 ;
UPDATE product SET productName = 'R3303', productDescription = '', productCatId = '1', productBuyPrice = '295.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2024-11-22', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3303',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '295',lastbuyprice_withDiscount = '295',meanbuyprice = '294',meanbuyprice_withDiscount = '294' , productbuypricereal = '285.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='285',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='295',meanbuyprice_withTax='294',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='295'  WHERE productId = '16077';
UPDATE buybilldetail SET  lastbuyprice = 295 , meanbuyprice = 294, lastbuyprice_withDiscount = 295, meanbuyprice_withDiscount = 294
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 294, lastbuyprice_withDiscountAndTax = 295
                where buybilldetailid = 32889;
UPDATE productunit SET proUnitBuyPrice  = 295 * productnumber WHERE productid = 16077;
UPDATE storedetail SET  productquantity = '34', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16076';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16077', '1', '30', '0', '14200', 'اضافة فاتورة مشتريات', 'buyBillController.php', '4', '34', '77', '2024-12-20 20:10:37','0','0');
UPDATE supplier SET  suppliercurrentDebt = '43170',suppliercurrentDebtInCurrency= '43170' , userid = '77', supplierdate = '2024-12-20 20:11:41'   WHERE supplierid = '49';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('49', '34320.00', '8850', '0', 'اضافة فاتورة مشتريات', '14200', '43170', '2024-12-20 20:10:37', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','8850','1','34320','8850','43170','0');
update buybill set dailyentryid='0,' where buybillid=14200;
COMMIT;
UPDATE product SET overAllAveragePrice = 289.62 WHERE productId = 16077;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:41:42";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:11:42", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:11:42', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14200');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:41:52";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:11:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:11:52', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:41:53";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:11:53", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:11:53', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:41:53";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:11:53", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:11:53', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765b1ebdec46
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 20:05:31', '06765b1ebdec46', '1', '0.00', '0', '20', '1', '610.00', '590', '590', '0', '1', '2024-12-20 20:11:54', '', '9', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','590','0','','0','0','590','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150493', '0', '2024-12-20 20:11:54', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '590', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 20:05:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36085;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('525','R3330', '150493', '1', '16365', '1', '610', '610', '0', '', '1', '2024-12-20 20:11:54', '16365', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36085-1,','1','1','0','0','610','610','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 525.00 , meanbuyprice = 525.00, lastbuyprice_withDiscount = 525.00, meanbuyprice_withDiscount = 525.00
        , lastbuyprice_withTax = 525, meanbuyprice_withTax = 525, lastbuyprice_withDiscountAndTax = 525
                where sellbilldetailid = 549875;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16365, '2024-12-20', 590, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+590, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 590, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+590, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '9', storedetaildate = '2024-12-20 20:11:54' WHERE storedetailid = '16364';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16365', '1', '1', '1', '150493', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '9', '2024-12-20 20:11:54','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '4715',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('4125','590', '0', '1', 'اضافة فاتورة مبيعات', '150493', '4715', '2024-12-20 20:11:54', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 590, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+590, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 590, 525, 525
                    , 525, 525, 525, 525
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,525, 525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+590, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 590, 525, 525
                    , 525, 525, 525, 525, 525, 525)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+590, netSellCostBuyPrice = netSellCostBuyPrice+525
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+525
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+525
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+525
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+525
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+525
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+525
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+525;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765b1ebdec46 and sellbillId = 150493 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:41:54";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:11:54", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:11:54', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:42:03";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:12:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:12:03', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:42:10";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:12:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:12:10', '2', 'delete', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=delete&sellbillid=148624&action=0');

-- ----------------------------------------------------------------------------------------------------
-- bill delete start - sellbill with id = 148624
-- ----------------------------------------------------------------------------------------------------

BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 148624;
UPDATE sellbill SET  sellbillsysdate = '2024-12-20 20:12:10', userid = '75',delbyuserid = '2', conditions = '1'  ,billReservation= 0,billReservationDate='0000-00-00'  WHERE sellbillid = '148624';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 32048;
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 542895;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14416, '2024-12-20', 250, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-250, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 250, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-250, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '6', userid = '2', storedetaildate = '2024-12-20 20:12:10' WHERE storedetailid = '14415';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14416', '1', '1', '0', '148624', 'حذف فاتورة مبيعات', 'sellbillController.php', '5', '6', '2', '2024-12-20 20:12:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 32113;
UPDATE sellbilldetail SET  lastbuyprice = 175.00 , meanbuyprice = 175.00, lastbuyprice_withDiscount = 175.00, meanbuyprice_withDiscount = 175.00
        
                where sellbilldetailid = 542896;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14451, '2024-12-20', 145, 175, 175
                    , 175, 175, 175, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-145, sellCostBuyPrice =sellCostBuyPrice-175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-175, sellCostMeanBuyPrice = sellCostMeanBuyPrice-175
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-175
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-175
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 145, 175, 175
                    , 175, 175, 175, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-145, sellCostBuyPrice =sellCostBuyPrice-175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-175, sellCostMeanBuyPrice = sellCostMeanBuyPrice-175
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-175
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-175
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '4', userid = '2', storedetaildate = '2024-12-20 20:12:10' WHERE storedetailid = '14450';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14451', '1', '1', '0', '148624', 'حذف فاتورة مبيعات', 'sellbillController.php', '3', '4', '2', '2024-12-20 20:12:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 28122;
UPDATE sellbilldetail SET  lastbuyprice = 245.00 , meanbuyprice = 245.00, lastbuyprice_withDiscount = 245.00, meanbuyprice_withDiscount = 245.00
        
                where sellbilldetailid = 542897;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12527, '2024-12-20', 200, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-200, sellCostBuyPrice =sellCostBuyPrice-245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-245, sellCostMeanBuyPrice = sellCostMeanBuyPrice-245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-200, sellCostBuyPrice =sellCostBuyPrice-245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-245, sellCostMeanBuyPrice = sellCostMeanBuyPrice-245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '1', userid = '2', storedetaildate = '2024-12-20 20:12:10' WHERE storedetailid = '12526';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12527', '1', '1', '0', '148624', 'حذف فاتورة مبيعات', 'sellbillController.php', '0', '1', '2', '2024-12-20 20:12:10','0','0');
CALL clientInUse(10647,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '2' WHERE clientid = '10647';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10647','621.00','621.00','1','حذف فاتورة مبيعات','148624', '0', '2024-12-20 20:12:10', '2', 'sellbillController.php', 'حذف فاتورة مبيعات', '621', '0', null, '0', null, null,'', '0','1','1','621','1','2024-12-09 16:05:56','0','0');
UPDATE client SET  inUse = 0 where clientid = 10647;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 621, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-621, sellCostBuyPrice =sellCostBuyPrice-670
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-670, sellCostMeanBuyPrice = sellCostMeanBuyPrice-670
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-670, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-670
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-670
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10647, '2024-12-20', 621, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-621, sellCostBuyPrice =sellCostBuyPrice-670
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-670, sellCostMeanBuyPrice = sellCostMeanBuyPrice-670
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-670, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-670
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-670
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 621, 670, 670
                    , 670, 670, 670, 670, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-621, netSellCostBuyPrice = netSellCostBuyPrice-670
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-670
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-670
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-670
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-670
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-670
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill delete end - sellbill with id = 148624
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:42:11";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:12:11", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:12:11', '2', 'sucess', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:42:13";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:12:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:12:13', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7363','','5','495','580', '580','580', '2024-12-20', '0', '77', '1', '07363', '0', '0', '0', '0', '0', '495','495','495','495','495','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','495','495','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16563, 1,'2024-12-20 20:12:22',77)
                ON DUPLICATE KEY UPDATE productid = 16563, edited = 1, sysdate = '2024-12-20 20:12:22', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16563', '1', '2024-12-20', '77', '0','1656301','580','580','580','495','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16563', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16563', '1', '0', '0', '16563', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7364','','5','575','660', '660','660', '2024-12-20', '0', '77', '1', '07364', '0', '0', '0', '0', '0', '575','575','575','575','575','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','575','575','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16564, 1,'2024-12-20 20:12:55',77)
                ON DUPLICATE KEY UPDATE productid = 16564, edited = 1, sysdate = '2024-12-20 20:12:55', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16564', '1', '2024-12-20', '77', '0','1656401','660','660','660','575','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16564', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16564', '1', '0', '0', '16564', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE productunit SET unitid = '1', productid = '16211', productnumber = '1.00', productunitdate = '2024-11-30', userid = '77', conditions = '0',proUnitParcode='1621101',proUnitSellAllPrice='230',proUnitSellHalfPrice='230',proUnitSellUnitPrice ='230',proUnitBuyPrice='175',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16211';
UPDATE product SET productName = '7154', productDescription = '', productCatId = '5', productBuyPrice = '170', productSellAllPrice = '230', productSellUnitPrice = '230', productSellHalfPrice = '230', productDate = '2024-11-30', conditions = '0', userId = '77', limitamount = '1', parcode = '12339',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '172.5',meanbuyprice_withDiscount = '172.5' , productbuypricereal = '175' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='175',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='175',meanbuyprice_withTax='175',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='175'  WHERE productId = '16211';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7366','','5','175','235', '235','235', '2024-12-20', '0', '77', '1', '07366', '0', '0', '0', '0', '0', '175','175','175','175','175','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','175','175','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16565, 1,'2024-12-20 20:13:50',77)
                ON DUPLICATE KEY UPDATE productid = 16565, edited = 1, sysdate = '2024-12-20 20:13:50', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16565', '1', '2024-12-20', '77', '0','1656501','235','235','235','175','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16565', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16565', '1', '0', '0', '16565', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:44:09";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:14:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 20:14:09', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:44:09";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:44:10";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:14:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 20:14:10', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:44:11";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:44:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:14:27", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:14:27', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:45:19";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:15:19", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:15:19', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765b4037017b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 20:14:27', '06765b4037017b', '1', '0.00', '0', '0', '1', '600.00', '600', '600', '0', '1', '2024-12-20 20:15:19', '', '9', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','600','0','','0','0','600','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150494', '0', '2024-12-20 20:15:20', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '600', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 20:14:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36339;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('550','07227', '150494', '5', '16282', '1', '600', '600', '0', '', '1', '2024-12-20 20:15:20', '16282', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36339-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 550.00 , meanbuyprice = 550.00, lastbuyprice_withDiscount = 550.00, meanbuyprice_withDiscount = 550.00
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 437, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 549876;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16282, '2024-12-20', 600, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 550, 437, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+437
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 437, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+437
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '9', storedetaildate = '2024-12-20 20:15:20' WHERE storedetailid = '16281';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16282', '1', '1', '1', '150494', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '9', '2024-12-20 20:15:20','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '5315',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('4715','600', '0', '1', 'اضافة فاتورة مبيعات', '150494', '5315', '2024-12-20 20:15:20', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 600, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 437, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+437
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 437, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+437
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 600, 550, 550
                    , 550, 550, 550, 550, 550, 437)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+600, netSellCostBuyPrice = netSellCostBuyPrice+550
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+550
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+550
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+550
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+550
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+550
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+550
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+437;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765b4037017b and sellbillId = 150494 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:45:20";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:15:20", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:15:20', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:46:31";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:16:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:16:31', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765b36af2434
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 20:11:54', '06765b36af2434', '1', '0.00', '0', '0', '1', '180.00', '180', '180', '0', '1', '2024-12-20 20:16:31', '', '9', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','180','0','','0','0','180','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150495', '0', '2024-12-20 20:16:31', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '180', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 20:11:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36493;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('130','07322', '150495', '5', '16484', '1', '180', '180', '0', '', '1', '2024-12-20 20:16:31', '16484', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36493-1,','1','1','0','0','180','180','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 130.00 , meanbuyprice = 130.00, lastbuyprice_withDiscount = 130.00, meanbuyprice_withDiscount = 130.00
        , lastbuyprice_withTax = 130, meanbuyprice_withTax = 130, lastbuyprice_withDiscountAndTax = 130
                where sellbilldetailid = 549877;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16484, '2024-12-20', 180, 130, 130
                    , 130, 130, 130, 130
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 130, 130, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+130
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+130, sellCostMeanBuyPrice = sellCostMeanBuyPrice+130
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+130, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+130
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+130
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+130
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+130
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 180, 130, 130
                    , 130, 130, 130, 130
                    , 0, 0, 0, 0
                    , 0, 0, 0, 130, 130, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+130
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+130, sellCostMeanBuyPrice = sellCostMeanBuyPrice+130
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+130, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+130
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+130
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+130
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+130
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '9', storedetaildate = '2024-12-20 20:16:31' WHERE storedetailid = '16483';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16484', '1', '1', '1', '150495', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '9', '2024-12-20 20:16:31','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '5495',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('5315','180', '0', '1', 'اضافة فاتورة مبيعات', '150495', '5495', '2024-12-20 20:16:31', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 180, 130, 130
                    , 130, 130, 130, 130
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,130, 130, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+130
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+130, sellCostMeanBuyPrice = sellCostMeanBuyPrice+130
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+130, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+130
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+130
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+130
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+130
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 180, 130, 130
                    , 130, 130, 130, 130
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,130, 130, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+130
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+130, sellCostMeanBuyPrice = sellCostMeanBuyPrice+130
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+130, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+130
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+130
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+130
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+130
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 180, 130, 130
                    , 130, 130, 130, 130, 130, 130)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+180, netSellCostBuyPrice = netSellCostBuyPrice+130
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+130
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+130
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+130
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+130
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+130
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+130
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+130;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765b36af2434 and sellbillId = 150495 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:46:31";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:16:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:16:31', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:50:49";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:20:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 20:20:49', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:50:52";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:20:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 20:20:52', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:52:18";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:22:18", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:22:18', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765b438c8bd1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 20:15:20', '06765b438c8bd1', '1', '0.00', '0', '0', '1', '600.00', '600', '600', '0', '1', '2024-12-20 20:22:18', '', '9', '0', 'نقدي', '1', '0', '3', '73', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','600','0','','0','0','600','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150496', '0', '2024-12-20 20:22:18', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '600', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 20:15:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36096;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('550','R3205', '150496', '1', '15411', '1', '600', '600', '0', '', '1', '2024-12-20 20:22:18', '15411', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36096-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 550.00 , meanbuyprice = 548.00, lastbuyprice_withDiscount = 550.00, meanbuyprice_withDiscount = 548.00
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 471, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 549878;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15411, '2024-12-20', 600, 550, 550
                    , 548, 550, 548, 502.35
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 550, 471, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+548
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+548
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+502.35
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+471
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 550, 550
                    , 548, 550, 548, 502.35
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 471, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+548
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+548
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+502.35
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+471
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '80', userid = '9', storedetaildate = '2024-12-20 20:22:18' WHERE storedetailid = '15410';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15411', '1', '1', '1', '150496', 'اضافة فاتورة مبيعات', 'sellbillController.php', '81', '80', '9', '2024-12-20 20:22:18','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6095',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('5495','600', '0', '1', 'اضافة فاتورة مبيعات', '150496', '6095', '2024-12-20 20:22:18', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 73 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 600, 550, 550
                    , 548, 550, 548, 502.35
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 471, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+548
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+548
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+502.35
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+471
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 600, 550, 550
                    , 548, 550, 548, 502.35
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 471, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+548
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+548
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+502.35
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+471
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 600, 550, 550
                    , 548, 550, 548, 502.35, 550, 471)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+600, netSellCostBuyPrice = netSellCostBuyPrice+550
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+550
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+548
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+550
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+548
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+502.35
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+550
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+471;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765b438c8bd1 and sellbillId = 150496 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:52:19";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:22:19", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:22:19', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:53:26";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:23:26", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:23:26', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765b5db66efc
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 20:22:19', '06765b5db66efc', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2024-12-20 20:23:26', '', '9', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150497', '0', '2024-12-20 20:23:26', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 20:22:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31749;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('260','R2865', '150497', '1', '14268', '1', '200', '200', '0', '', '1', '2024-12-20 20:23:26', '14268', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31749-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 260.00
        
                where sellbilldetailid = 549879;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14268, '2024-12-20', 200, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '9', storedetaildate = '2024-12-20 20:23:26' WHERE storedetailid = '14267';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14268', '1', '1', '1', '150497', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '9', '2024-12-20 20:23:26','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6295',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6095','200', '0', '1', 'اضافة فاتورة مبيعات', '150497', '6295', '2024-12-20 20:23:26', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 200, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 200, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 200, 260, 260
                    , 260, 260, 260, 260, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+260
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+260
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+260
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+260
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+260
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+260
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765b5db66efc and sellbillId = 150497 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:53:26";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:23:26", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:23:26', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:55:12";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:25:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 20:25:12', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:55:24";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:25:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 20:25:24', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:55:30";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:25:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:25:30', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150450');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:56:14";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:26:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 20:26:14', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:56:18";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:26:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:26:18', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150489');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:56:44";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:26:44", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:26:44', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765b4801130d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 20:16:32', '06765b4801130d', '1', '0.00', '0', '0', '1', '290.00', '290', '290', '0', '1', '2024-12-20 20:26:44', '', '9', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','290','0','','0','0','290','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150498', '0', '2024-12-20 20:26:44', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '290', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 20:16:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36438;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','07100', '150498', '5', '16114', '1', '290', '290', '0', '', '1', '2024-12-20 20:26:44', '16114', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36438-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 549880;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16114, '2024-12-20', 290, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '30', userid = '9', storedetaildate = '2024-12-20 20:26:45' WHERE storedetailid = '16113';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16114', '1', '1', '1', '150498', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31', '30', '9', '2024-12-20 20:26:45','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6585',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6295','290', '0', '1', 'اضافة فاتورة مبيعات', '150498', '6585', '2024-12-20 20:26:45', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 290, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 290, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 290, 240, 240
                    , 240, 240, 240, 240, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+290, netSellCostBuyPrice = netSellCostBuyPrice+240
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+240
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+240
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+240
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+240
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+240
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+240
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+240;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765b4801130d and sellbillId = 150498 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:56:45";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:26:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 20:26:45', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:56:45";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:26:45", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:26:45', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:56:49";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:26:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:26:49', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150086');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:57:13";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:27:13", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:27:13', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:57:38";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:27:38", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:27:38', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765b701d5df5
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,autoSaveFlag,obgyBillType,billoperationid,obygyVisitId,pricetype,currencyId,sellbillno) VALUES ('2024-12-20 20:27:13', '06765b701d5df5', '1', '0.00', '0', '0', '1', '420', '420', '-420', '0', '1', '2024-12-20 20:27:38', '', '9', '0', 'نقدي','1', '0', '5', '6', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-420','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16856', '0', '2024-12-20 20:27:38', '9', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '420', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 20:27:13','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('330.00', 'H1645', '16856', '14', '16372', '1', '420', '420', '0', '', '1', '0', '16372', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','420','420','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
        , lastbuyprice_withTax = 330, meanbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 330
                where returnsellbilldetailid = 22047;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16372, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 420, 330, 330, 330
                    , 330, 330, 330, 0, 1, 0, 0, 330, 330)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+420, returnSellCostBuyPrice = returnSellCostBuyPrice+330, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+330
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+330, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+330
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+330
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+330
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+330
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+330
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 420, 330, 330, 330
                    , 330, 330, 330, 0, 0, 330, 330)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+420, returnSellCostBuyPrice = returnSellCostBuyPrice+330, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+330
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+330, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+330
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+330
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+330
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+330
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+330;
UPDATE storedetail SET  productquantity = '13', userid = '9', storedetaildate = '2024-12-20 20:27:38' WHERE storedetailid = '16371';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16372', '1', '1', '0', '16856', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '12', '13', '9', '2024-12-20 20:27:38','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6165',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6585','-420', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16856', '6165', '2024-12-20 20:27:38', '9',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 420, 330, 330, 330
                    , 330, 330, 330 ,0, 0, 330, 330)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+420, returnSellCostBuyPrice = returnSellCostBuyPrice+330, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+330
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+330, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+330
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+330
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+330
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+330
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+330;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 420, 330, 330, 330
                    , 330, 330, 330 ,0, 0, 330, 330)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+420, returnSellCostBuyPrice = returnSellCostBuyPrice+330, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+330
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+330, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+330
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+330
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+330
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+330
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+330;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -420, -330, -330
                    , -330, -330, -330, -330, -330, -330)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-420, netSellCostBuyPrice = netSellCostBuyPrice+-330
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-330
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-330
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-330
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-330
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-330
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-330
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-330;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765b701d5df5 and sellbillId = 16856 and returnsellbillId = 16856
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:57:38";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:27:39", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:27:39', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:58:26";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:28:26", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 20:28:26', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:58:37";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:28:37", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 20:28:37', '9', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'النون', '', '200', '2024-12-20', '9', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '5965',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6165.00','200', '1', '1', 'إضافة مصروف', '25915', '5965', '2024-12-20 20:28:38', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'النون', expensesdetails = '', expensesValue = '200.00', expensesdate = '2024-12-20', userid = '9', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25915';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:58:38";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:28:38", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 20:28:38', '9', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:58:39";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:28:39", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 20:28:39', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:58:45";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:28:45", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 20:28:45', '9', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'مروان', '', '150', '2024-12-20', '9', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '5815',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('5965.00','150', '1', '1', 'إضافة مصروف', '25916', '5815', '2024-12-20 20:28:45', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'مروان', expensesdetails = '', expensesValue = '150.00', expensesdate = '2024-12-20', userid = '9', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25916';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:58:46";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:28:46", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 20:28:46', '9', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:58:47";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:28:47", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 20:28:47', '9', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7372','','5','495','580', '580','580', '2024-12-20', '0', '77', '1', '07372', '0', '0', '0', '0', '0', '495','495','495','495','495','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','495','495','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16566, 1,'2024-12-20 20:29:07',77)
                ON DUPLICATE KEY UPDATE productid = 16566, edited = 1, sysdate = '2024-12-20 20:29:07', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16566', '1', '2024-12-20', '77', '0','1656601','580','580','580','495','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16566', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16566', '1', '0', '0', '16566', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:59:07";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:29:07", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:29:07', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765b6e5b3c65
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 20:26:45', '06765b6e5b3c65', '1', '0.00', '0', '0', '1', '800.00', '800', '800', '0', '1', '2024-12-20 20:29:07', '', '9', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','800','0','','0','0','800','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150499', '0', '2024-12-20 20:29:07', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '800', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 20:26:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36015;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('325','H1641', '150499', '14', '16346', '2', '400', '800', '0', '', '1', '2024-12-20 20:29:07', '16346', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36015-2,','1','1','0','0','400','800','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 325.00 , meanbuyprice = 325.00, lastbuyprice_withDiscount = 325.00, meanbuyprice_withDiscount = 325.00
        , lastbuyprice_withTax = 325, meanbuyprice_withTax = 325, lastbuyprice_withDiscountAndTax = 325
                where sellbilldetailid = 549881;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16346, '2024-12-20', 800, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 650, 650, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+650
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 800, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0, 650, 650, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+650
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '36', userid = '9', storedetaildate = '2024-12-20 20:29:07' WHERE storedetailid = '16345';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16346', '1', '2', '1', '150499', 'اضافة فاتورة مبيعات', 'sellbillController.php', '38', '36', '9', '2024-12-20 20:29:07','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6615',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('5815','800', '0', '1', 'اضافة فاتورة مبيعات', '150499', '6615', '2024-12-20 20:29:07', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 800, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,650, 650, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+650
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 800, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,650, 650, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+650
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 800, 650, 650
                    , 650, 650, 650, 650, 650, 650)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+800, netSellCostBuyPrice = netSellCostBuyPrice+650
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+650
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+650
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+650
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+650
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+650
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+650
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+650;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765b6e5b3c65 and sellbillId = 150499 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:59:08";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:29:08", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:29:08', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:59:54";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:29:54", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:29:54', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765a7e4d77a9', '2024-12-20 19:22:44', '6', '307180.00', '322030', '0', '0', '14850',  '14850', '0', '14850', '1', '2024-12-20 20:29:54', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07372', '14201', '5', '16566', '15', '495', '7425', '0', '', '2024-12-20 20:29:54', '16566','','','0','0','0','0','0',null,'495','7425','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:22:44', 1, 16566, 0, 0
                    , 495, 15, 0, 0, 77, '2024-12-20 20:29:54')
                ON DUPLICATE KEY UPDATE buyprice = 495,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:29:54' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16566', '495', '15', '0', 'buyBillController.php', '32890', '', '0', '0');
UPDATE product SET  productBuyPrice = "495" WHERE productId = 16566 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32890 ;
UPDATE product SET productName = '7372', productDescription = '', productCatId = '5', productBuyPrice = '495.00', productSellAllPrice = '580.00', productSellUnitPrice = '580.00', productSellHalfPrice = '580.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07372',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '495',lastbuyprice_withDiscount = '495',meanbuyprice = '495',meanbuyprice_withDiscount = '495' , productbuypricereal = '495.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='495',meanbuyprice_withTax='495',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='495'  WHERE productId = '16566';
UPDATE buybilldetail SET  lastbuyprice = 495 , meanbuyprice = 495, lastbuyprice_withDiscount = 495, meanbuyprice_withDiscount = 495
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 495, lastbuyprice_withDiscountAndTax = 495
                where buybilldetailid = 32890;
UPDATE productunit SET proUnitBuyPrice  = 495 * productnumber WHERE productid = 16566;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16565';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16566', '1', '15', '0', '14201', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:22:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07363', '14201', '5', '16563', '15', '495', '7425', '0', '', '2024-12-20 20:29:54', '16563','','','0','0','0','0','0',null,'495','7425','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 19:22:44', 1, 16563, 0, 0
                    , 495, 15, 0, 0, 77, '2024-12-20 20:29:54')
                ON DUPLICATE KEY UPDATE buyprice = 495,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:29:54' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16563', '495', '15', '0', 'buyBillController.php', '32891', '', '0', '0');
UPDATE product SET  productBuyPrice = "495" WHERE productId = 16563 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32891 ;
UPDATE product SET productName = '7363', productDescription = '', productCatId = '5', productBuyPrice = '495.00', productSellAllPrice = '580.00', productSellUnitPrice = '580.00', productSellHalfPrice = '580.00', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = '07363',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '495',lastbuyprice_withDiscount = '495',meanbuyprice = '495',meanbuyprice_withDiscount = '495' , productbuypricereal = '495.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='495',meanbuyprice_withTax='495',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='495'  WHERE productId = '16563';
UPDATE buybilldetail SET  lastbuyprice = 495 , meanbuyprice = 495, lastbuyprice_withDiscount = 495, meanbuyprice_withDiscount = 495
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 495, lastbuyprice_withDiscountAndTax = 495
                where buybilldetailid = 32891;
UPDATE productunit SET proUnitBuyPrice  = 495 * productnumber WHERE productid = 16563;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '16562';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16563', '1', '15', '0', '14201', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-20 19:22:44','0','0');
UPDATE supplier SET  suppliercurrentDebt = '322030',suppliercurrentDebtInCurrency= '322030' , userid = '77', supplierdate = '2024-12-20 20:29:54'   WHERE supplierid = '6';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('6', '307180.00', '14850', '0', 'اضافة فاتورة مشتريات', '14201', '322030', '2024-12-20 19:22:44', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','14850','1','307180','14850','322030','0');
update buybill set dailyentryid='0,' where buybillid=14201;
COMMIT;
UPDATE product SET overAllAveragePrice = 495 WHERE productId = 16563;UPDATE product SET overAllAveragePrice = 495 WHERE productId = 16566;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:59:54";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:29:54", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:29:54', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14201');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 16:59:56";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:29:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 20:29:56', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:00:14";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:30:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 20:30:14', '2', 'add', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248115
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(347,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '5' , clientdate = '2024-12-20 20:30:14', userid = '2' WHERE clientid = '347';
UPDATE client SET  inUse = 0 where clientid = 347;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('347','585.00','580','1','ايصال تحصيل (( قبض من عميل ))','248115', '5', '2024-12-20 20:29:57', '2', 'clientPayedDeptController.php', '   ', '580', '0', null, '0', null, null,'', '-1','1','1','580','1','','3685','0');
UPDATE save SET  savecurrentvalue = '177460.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('176880.50','580', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248115', '177460.5', '2024-12-20 20:30:14', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '580', '580', '2024-12-20', '2', '0', '0', '2024-12-20 20:30:14','اضافة ايصال سداد للعميل سهيلة محمد y35','1','0','0','0','248115','clientPayedDeptController.php?do=show&id=248115');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122354', '-1', '580', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '580', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122354', '-1', '580', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-580', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '347', clientdebtchangebefore = '585.000', clientdebtchangeamount = '580.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248115', clientdebtchangeafter = '5.000', clientdebtchangedate = '2024-12-20 20:29:57', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '580.00',discount='', reciptid='0', dailyentryid = '122354',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='580',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248115';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248115 -clientdebtchangeId = 248115
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:00:15";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:30:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 20:30:15', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:00:31";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:30:31", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:30:31', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('R3351','','1','440','530', '530','530', '2024-12-20', '0', '77', '1', 'R3351', '0', '0', '0', '0', '0', '440','440','440','440','440','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','440','440','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16567, 1,'2024-12-20 20:31:40',77)
                ON DUPLICATE KEY UPDATE productid = 16567, edited = 1, sysdate = '2024-12-20 20:31:40', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16567', '1', '2024-12-20', '77', '0','1656701','530','530','530','440','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16567', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16567', '1', '0', '0', '16567', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:01:47";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:31:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 20:31:47', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:01:54";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:31:54", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 20:31:54', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:01:59";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:31:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:31:59', '2', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150489');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:02:14";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:32:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 20:32:14', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:02:21";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:32:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:32:21', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150260');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('H1680','','14','440','520', '520','520', '2024-12-20', '0', '77', '1', 'H1680', '0', '0', '0', '0', '0', '440','440','440','440','440','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','440','440','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16568, 1,'2024-12-20 20:32:21',77)
                ON DUPLICATE KEY UPDATE productid = 16568, edited = 1, sysdate = '2024-12-20 20:32:21', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16568', '1', '2024-12-20', '77', '0','1656801','520','520','520','440','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16568', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16568', '1', '0', '0', '16568', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE productunit SET unitid = '1', productid = '16567', productnumber = '1.00', productunitdate = '2024-12-20', userid = '77', conditions = '0',proUnitParcode='1656701',proUnitSellAllPrice='530',proUnitSellHalfPrice='530',proUnitSellUnitPrice ='530',proUnitBuyPrice='440',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16567';
UPDATE product SET productName = 'R3351', productDescription = '', productCatId = '1', productBuyPrice = '310', productSellAllPrice = '530', productSellUnitPrice = '530', productSellHalfPrice = '530', productDate = '2024-12-20', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3351',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '440.00',lastbuyprice_withDiscount = '440',meanbuyprice = '375',meanbuyprice_withDiscount = '375' , productbuypricereal = '440' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='440',meanbuyprice_withTax='440',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='0'  WHERE productId = '16567';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7330','','5','165','220', '220','220', '2024-12-20', '0', '77', '1', '07330', '0', '0', '0', '0', '0', '165','165','165','165','165','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','165','165','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16569, 1,'2024-12-20 20:33:02',77)
                ON DUPLICATE KEY UPDATE productid = 16569, edited = 1, sysdate = '2024-12-20 20:33:02', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16569', '1', '2024-12-20', '77', '0','1656901','220','220','220','165','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16569', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16569', '1', '0', '0', '16569', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7328','','5','400','500', '500','500', '2024-12-20', '0', '77', '1', '07328', '0', '0', '0', '0', '0', '400','400','400','400','400','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','400','400','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16570, 1,'2024-12-20 20:33:23',77)
                ON DUPLICATE KEY UPDATE productid = 16570, edited = 1, sysdate = '2024-12-20 20:33:23', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16570', '1', '2024-12-20', '77', '0','1657001','500','500','500','400','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16570', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16570', '1', '0', '0', '16570', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7370','','5','245','310', '310','310', '2024-12-20', '0', '77', '1', '07370', '0', '0', '0', '0', '0', '245','245','245','245','245','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','245','245','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16571, 1,'2024-12-20 20:34:01',77)
                ON DUPLICATE KEY UPDATE productid = 16571, edited = 1, sysdate = '2024-12-20 20:34:01', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16571', '1', '2024-12-20', '77', '0','1657101','310','310','310','245','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16571', '1', '0', '77', '2024-12-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16571', '1', '0', '0', '16571', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:05:16";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:35:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 20:35:16', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:05:21";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:35:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:35:21', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150350');
UPDATE productunit SET unitid = '1', productid = '16052', productnumber = '1.00', productunitdate = '2024-11-21', userid = '77', conditions = '0',proUnitParcode='1605201',proUnitSellAllPrice='400',proUnitSellHalfPrice='400',proUnitSellUnitPrice ='400',proUnitBuyPrice='350',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16052';
UPDATE product SET productName = '7074', productDescription = '', productCatId = '5', productBuyPrice = '345', productSellAllPrice = '400', productSellUnitPrice = '400', productSellHalfPrice = '400', productDate = '2024-11-21', conditions = '0', userId = '77', limitamount = '1', parcode = '07074',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '350.00',lastbuyprice_withDiscount = '350',meanbuyprice = '347.5',meanbuyprice_withDiscount = '347.5' , productbuypricereal = '350' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='350',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='350',meanbuyprice_withTax='350',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='350'  WHERE productId = '16052';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:07:51";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:37:51", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:37:51', '77', 'bill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:08:16";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:38:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 20:38:16', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:08:20";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-20 20:38:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:38:20', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150406');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:08:21";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:38:21", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:38:21', '77', 'add', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO buybill (buybillSerial, buybilldate, buybillsupplierid, buybilltotaldeptbefor, buybilltotaldeptafter, buybilldiscount, buybilldiscountrype, buybilltotalbill, buybillaftertotalbill, buybilltotalpayed, buybillfinalbill, buybillstoreid, buybillsysdate,comment, userid, conditions, buybillclientname, buybillsaveid, buybilldirectpayment, billnameid,payedtax,costcenterid,dailyentryid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,files,client,totalBuyDiscountVal,webApiId) VALUES ('06765b97fb609d', '2024-12-20 20:37:51', '9', '299750.00', '303550', '0', '0', '3800',  '3800', '0', '3800', '1', '2024-12-20 20:38:21', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1496', '14202', '14', '15942', '10', '380', '3800', '0', '', '2024-12-20 20:38:21', '15942','','','0','0','0','0','0',null,'380','3800','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-20 20:37:51', 1, 15942, 0, 0
                    , 380, 10, 0, 0, 77, '2024-12-20 20:38:21')
                ON DUPLICATE KEY UPDATE buyprice = 380,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-20 20:38:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15942', '380', '10', '0', 'buyBillController.php', '32892', '', '0', '0');
UPDATE product SET  productBuyPrice = "380" WHERE productId = 15942 ;
UPDATE buybilldetail SET  quantitybefore = 4 WHERE buybilldetailid = 32892 ;
UPDATE product SET productName = 'H1496', productDescription = '', productCatId = '14', productBuyPrice = '380.00', productSellAllPrice = '470.00', productSellUnitPrice = '470.00', productSellHalfPrice = '470.00', productDate = '2024-11-11', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1496',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '380',lastbuyprice_withDiscount = '380',meanbuyprice = '380',meanbuyprice_withDiscount = '380' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='380',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='380',meanbuyprice_withTax='380',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='380'  WHERE productId = '15942';
UPDATE buybilldetail SET  lastbuyprice = 380 , meanbuyprice = 380, lastbuyprice_withDiscount = 380, meanbuyprice_withDiscount = 380
        , lastbuyprice_withTax = 380, meanbuyprice_withTax = 380, lastbuyprice_withDiscountAndTax = 380
                where buybilldetailid = 32892;
UPDATE productunit SET proUnitBuyPrice  = 380 * productnumber WHERE productid = 15942;
UPDATE storedetail SET  productquantity = '14', userid = '77', storedetaildate = '2024-12-20' WHERE storedetailid = '15941';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15942', '1', '10', '0', '14202', 'اضافة فاتورة مشتريات', 'buyBillController.php', '4', '14', '77', '2024-12-20 20:37:51','0','0');
UPDATE supplier SET  suppliercurrentDebt = '303550',suppliercurrentDebtInCurrency= '303550' , userid = '77', supplierdate = '2024-12-20 20:38:21'   WHERE supplierid = '9';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('9', '299750.00', '3800', '0', 'اضافة فاتورة مشتريات', '14202', '303550', '2024-12-20 20:37:51', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','3800','1','299750','3800','303550','0');
update buybill set dailyentryid='0,' where buybillid=14202;
COMMIT;
UPDATE product SET overAllAveragePrice = 380 WHERE productId = 15942;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:08:22";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:38:22", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-20 20:38:22', '77', 'editprint', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14202');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:08:28";
UPDATE user SET loginip = "192.168.1.29", lastactivetime = "2024-12-20 20:38:28", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-20 20:38:28', '77', 'showbarcodebuybill', '192.168.1.29', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14202&type=2');
UPDATE user SET loginip = "" WHERE userid = 77;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:10:14";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:40:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 20:40:14', '2', 'add', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248116
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8344,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 20:40:14', userid = '2' WHERE clientid = '8344';
UPDATE client SET  inUse = 0 where clientid = 8344;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8344','745.00','745','1','ايصال تحصيل (( قبض من عميل ))','248116', '0', '2024-12-20 20:30:15', '2', 'clientPayedDeptController.php', '   ', '745', '0', null, '0', null, null,'', '-1','1','1','745','1','','3686','0');
UPDATE save SET  savecurrentvalue = '178205.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('177460.50','745', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248116', '178205.5', '2024-12-20 20:40:14', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '745', '745', '2024-12-20', '2', '0', '0', '2024-12-20 20:40:14','اضافة ايصال سداد للعميل ايمان الغردقة I1115','1','0','0','0','248116','clientPayedDeptController.php?do=show&id=248116');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122355', '-1', '745', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '745', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122355', '-1', '745', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-745', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '8344', clientdebtchangebefore = '745.000', clientdebtchangeamount = '745.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248116', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 20:30:15', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '745.00',discount='', reciptid='0', dailyentryid = '122355',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='745',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248116';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248116 -clientdebtchangeId = 248116
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:10:15";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:40:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 20:40:15', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:10:45";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:40:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 20:40:45', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:12:22";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:42:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 20:42:22', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:12:38";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:42:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 20:42:38', '2', 'add', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =248117
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6597,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20 20:42:38', userid = '2' WHERE clientid = '6597';
UPDATE client SET  inUse = 0 where clientid = 6597;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6597','390.00','390','1','ايصال تحصيل (( قبض من عميل ))','248117', '0', '2024-12-20 20:42:22', '2', 'clientPayedDeptController.php', '   ', '390', '0', null, '0', null, null,'', '-1','1','1','390','1','','3687','0');
UPDATE save SET  savecurrentvalue = '178595.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('178205.50','390', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '248117', '178595.5', '2024-12-20 20:42:38', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '390', '390', '2024-12-20', '2', '0', '0', '2024-12-20 20:42:38','اضافة ايصال سداد للعميل سوما ستور 41','1','0','0','0','248117','clientPayedDeptController.php?do=show&id=248117');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122356', '-1', '390', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '390', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122356', '-1', '390', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-390', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '6597', clientdebtchangebefore = '390.000', clientdebtchangeamount = '390.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '248117', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-20 20:42:22', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '390.00',discount='', reciptid='0', dailyentryid = '122356',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='390',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '248117';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =248117 -clientdebtchangeId = 248117
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:12:38";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:42:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 20:42:38', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:13:02";
UPDATE user SET loginip = "45.245.216.202", lastactivetime = "2024-12-20 20:43:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 20:43:02', '1', '', '45.245.216.202', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:13:03";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:13:31";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 20:43:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 20:43:31', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:13:56";
UPDATE user SET loginip = "45.245.216.202", lastactivetime = "2024-12-20 20:43:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('saveController.php', '2024-12-20 20:43:56', '1', 'show', '45.245.216.202', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/saveController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:15:13";
UPDATE user SET loginip = "45.245.216.202", lastactivetime = "2024-12-20 20:45:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storeController.php', '2024-12-20 20:45:13', '1', 'show', '45.245.216.202', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storeController.php?do=show');
UPDATE user SET loginip = "" WHERE userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:15:27";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:45:27", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 20:45:27', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:15:33";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:45:33", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 20:45:33', '9', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'جنه', '', '300', '2024-12-20', '9', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '6315',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6615.00','300', '1', '1', 'إضافة مصروف', '25917', '6315', '2024-12-20 20:45:33', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'جنه', expensesdetails = '', expensesValue = '300.00', expensesdate = '2024-12-20', userid = '9', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25917';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:15:34";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:45:34", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 20:45:34', '9', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:15:35";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:45:35", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 20:45:35', '9', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:16:25";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:46:25", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:46:25', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:18:32";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:48:32", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:48:32', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765bb8180239
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 20:46:25', '06765bb8180239', '1', '0.00', '0', '5', '1', '2205.00', '2200', '2200', '0', '1', '2024-12-20 20:48:32', '', '9', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','2200','0','','0','0','2200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150500', '0', '2024-12-20 20:48:32', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 20:46:25','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35786;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('950','H1602', '150500', '14', '16232', '1', '1160', '1160', '0', '', '1', '2024-12-20 20:48:32', '16232', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35786-1,','1','1','0','0','1160','1160','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 950.00 , meanbuyprice = 950.00, lastbuyprice_withDiscount = 950.00, meanbuyprice_withDiscount = 950.00
        , lastbuyprice_withTax = 950, meanbuyprice_withTax = 475, lastbuyprice_withDiscountAndTax = 950
                where sellbilldetailid = 549882;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16232, '2024-12-20', 1157.3696145125, 950, 950
                    , 950, 950, 950, 950
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 950, 475, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1157.3696145125, sellCostBuyPrice =sellCostBuyPrice+950
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+950, sellCostMeanBuyPrice = sellCostMeanBuyPrice+950
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+950, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+950
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+950
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+950
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+475
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 1157.3696145125, 950, 950
                    , 950, 950, 950, 950
                    , 0, 0, 0, 0
                    , 0, 0, 0, 950, 475, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1157.3696145125, sellCostBuyPrice =sellCostBuyPrice+950
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+950, sellCostMeanBuyPrice = sellCostMeanBuyPrice+950
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+950, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+950
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+950
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+950
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+475
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '9', storedetaildate = '2024-12-20 20:48:32' WHERE storedetailid = '16231';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16232', '1', '1', '1', '150500', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '9', '2024-12-20 20:48:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 27670;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('520','05672', '150500', '5', '12330', '1', '360', '360', '0', '', '1', '2024-12-20 20:48:32', '12330', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','27670-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 520.00 , meanbuyprice = 520.00, lastbuyprice_withDiscount = 520.00, meanbuyprice_withDiscount = 520.00
        
                where sellbilldetailid = 549883;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12330, '2024-12-20', 359.18367346939, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+359.18367346939, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 359.18367346939, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+359.18367346939, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '9', storedetaildate = '2024-12-20 20:48:32' WHERE storedetailid = '12329';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12330', '1', '1', '1', '150500', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '9', '2024-12-20 20:48:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31308;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('330','06199', '150500', '5', '14093', '1', '285', '285', '0', '', '1', '2024-12-20 20:48:32', '14093', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31308-1,','1','1','0','0','285','285','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
        
                where sellbilldetailid = 549884;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14093, '2024-12-20', 284.3537414966, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+284.3537414966, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 284.3537414966, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+284.3537414966, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '9', storedetaildate = '2024-12-20 20:48:32' WHERE storedetailid = '14092';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14093', '1', '1', '1', '150500', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '9', '2024-12-20 20:48:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36150;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('335','07221', '150500', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-20 20:48:32', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36150-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 549885;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16279, '2024-12-20', 399.09297052154, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+399.09297052154, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+330
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 399.09297052154, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+399.09297052154, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+330
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '140', userid = '9', storedetaildate = '2024-12-20 20:48:32' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150500', 'اضافة فاتورة مبيعات', 'sellbillController.php', '141', '140', '9', '2024-12-20 20:48:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '8515',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6315','2200', '0', '1', 'اضافة فاتورة مبيعات', '150500', '8515', '2024-12-20 20:48:32', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 2200, 2135, 2135
                    , 2135, 2135, 2135, 2135
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1285, 805, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2200, sellCostBuyPrice =sellCostBuyPrice+2135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2135, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2135
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2135
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2135
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+805
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 2200, 2135, 2135
                    , 2135, 2135, 2135, 2135
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1285, 805, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2200, sellCostBuyPrice =sellCostBuyPrice+2135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2135, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2135
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2135
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2135
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+805
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2200, 2135, 2135
                    , 2135, 2135, 2135, 2135, 1285, 805)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2200, netSellCostBuyPrice = netSellCostBuyPrice+2135
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2135
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2135
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2135
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2135
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2135
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1285
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+805;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765bb8180239 and sellbillId = 150500 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:18:33";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:48:33", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:48:33', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:18:41";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:48:41", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 20:48:41', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:21:05";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:51:05", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:51:05', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:21:30";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:51:30", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:51:30', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765bc99d5e71
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 20:51:05', '06765bc99d5e71', '1', '0.00', '0', '0', '1', '400.00', '400', '400', '0', '1', '2024-12-20 20:51:30', '', '9', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','400','0','','0','0','400','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150501', '0', '2024-12-20 20:51:30', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 20:51:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36097;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('360','07253', '150501', '5', '16370', '1', '400', '400', '0', '', '1', '2024-12-20 20:51:30', '16370', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36097-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 549886;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16370, '2024-12-20', 400, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '9', storedetaildate = '2024-12-20 20:51:30' WHERE storedetailid = '16369';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16370', '1', '1', '1', '150501', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '9', '2024-12-20 20:51:30','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '8915',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8515','400', '0', '1', 'اضافة فاتورة مبيعات', '150501', '8915', '2024-12-20 20:51:30', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 3 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 400, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 400, 360, 360
                    , 360, 360, 360, 360, 360, 360)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+400, netSellCostBuyPrice = netSellCostBuyPrice+360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+360
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+360
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+360
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+360
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+360;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765bc99d5e71 and sellbillId = 150501 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:21:31";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 20:51:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 20:51:31', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:46:09";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 21:16:09", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 21:16:09', '9', '', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:46:17";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 21:16:17", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 21:16:17', '9', 'add', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'محمد عبدة', '', '50', '2024-12-20', '9', '0','-1','1','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '8865',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8915.00','50', '1', '1', 'إضافة مصروف', '25918', '8865', '2024-12-20 21:16:17', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد عبدة', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-20', userid = '9', conditions = '0',saveid = '1' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25918';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:46:18";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 21:16:18", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 21:16:18', '9', 'sucess', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:46:20";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 21:16:20", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 21:16:20', '9', 'show', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:50:16";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:20:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 21:20:16', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:50:17";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:50:18";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:20:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-20 21:20:18', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

    create procedure generateParcodes (in num int)
    begin
        declare numLen int default CHAR_LENGTH(num);
        declare i int default 0;

        ALTER TABLE availableparcode ENGINE = MyISAM;

        while i <= num do
        insert into availableparcode (value) values (lpad(i, numLen, 0));
        set i = i + 1;
        end while;

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname,treeId INTO debtis,nameis,treeIdis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use","in_use" INTO debtis,nameis,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

CREATE PROCEDURE saveInUse(IN id INT, OUT saveidis INT, OUT savecurrentvalueis FLOAT, OUT currencyIdis INT, OUT treeIdis INT, OUT conversionFactoris FLOAT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM save WHERE saveid = id INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE save SET inUse = 1 WHERE saveid = id;
    SELECT saveid, savecurrentvalue, currencyId, treeId, currency.conversionFactor INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris
    FROM save
    LEFT JOIN currency ON currency.id = save.currencyId
    WHERE saveid = id;
  ELSE
    SELECT -10, -10, -10, -10, -10 INTO saveidis, savecurrentvalueis, currencyIdis, treeIdis, conversionFactoris;
  END IF;
END


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount decimal(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN `maincomment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,IN storetype INT,IN expireDate Text,IN priceType TEXT,IN recieveType INT,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment,maincomment,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,maincomment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment,maincomment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,expireDate,priceType,recieveType);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

CREATE PROCEDURE supplierInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256),OUT dailyid INT,OUT treeIdis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM supplier WHERE supplierid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update supplier set inUse=1 where supplierid = id;
        SELECT suppliercurrentDebt,suppliername,dailyentryid,treeId INTO debtis,nameis,dailyid,treeIdis FROM supplier WHERE supplierid = id ;
    ELSE
        SELECT "in_use","in_use","in_use","in_use" INTO debtis,nameis,dailyid,treeIdis;
    END IF;

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

CREATE PROCEDURE storedetailInUse(IN productidin INT,IN storeidin INT,IN unittypein INT,
OUT storedetailidis INT, OUT productidis INT, OUT storeidis INT, OUT productquantityis decimal(10,2), OUT useridis INT, OUT storedetaildateis DATE, OUT unittypeis INT)
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM storedetail WHERE productid = productidin and storeid=storeidin and unittype=unittypein INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE storedetail SET inUse = 1 WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
    SELECT storedetailid, productid, storeid, productquantity, userid,storedetaildate,unittype
        INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis
    FROM storedetail
    WHERE productid = productidin and storeid=storeidin and unittype=unittypein;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10 INTO storedetailidis, productidis, storeidis, productquantityis, useridis,storedetaildateis,unittypeis;
  END IF;
END


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

CREATE PROCEDURE sizeColorStoredetailInUseSP(IN idin INT,OUT idis INT, OUT storeidis INT, OUT productidis INT, OUT sizeidis INT,OUT coloridis INT,OUT parcodeis VARCHAR(300),
OUT buypriceis decimal(10,2),OUT sellunitpriceis decimal(10,2) ,OUT quantityis decimal(10,2), OUT useridis INT, OUT sysdateis DATE, OUT scdExcelParcodeis VARCHAR(12))
BEGIN
  DECLARE in_use_flag INT DEFAULT 1;
  SELECT inUse FROM sizecolorstoredetail WHERE id = idin INTO in_use_flag;

  IF in_use_flag = 0 THEN
    UPDATE sizecolorstoredetail SET inUse = 1 WHERE id = idin;
    SELECT id,storeid,productid,sizeid,colorid,parcode,buyprice,sellunitprice,quantity,userid,sysdate,scdExcelParcode
        INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis
    FROM sizecolorstoredetail
    WHERE id = idin;
  ELSE
    SELECT -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10 INTO idis, storeidis, productidis,sizeidis,coloridis,parcodeis,buypriceis,sellunitpriceis,quantityis,useridis,sysdateis,scdExcelParcodeis;
  END IF;
END


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:50:18";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:50:41";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:20:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:20:41', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:50:44";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:20:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:20:44', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:50:51";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:20:51", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:20:51', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:51:01";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:21:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:21:01', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:55:13";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:25:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:25:13', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:56:17";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:26:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:26:17', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:56:49";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:26:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:26:49', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:57:12";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:27:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:27:12', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:57:21";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:27:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:27:21', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:57:43";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:27:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:27:44', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:57:58";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:27:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:27:58', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:58:08";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:28:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:28:08', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:58:33";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:28:33", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:28:33', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:58:43";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:28:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:28:43', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:58:53";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:28:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:28:53', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:59:16";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:29:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:29:16', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 17:59:26";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:29:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:29:26', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:00:09";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:30:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:30:09', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:00:17";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:30:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:30:17', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:00:47";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:30:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:30:47', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:00:55";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:30:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:30:55', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:01:14";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:31:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:31:14', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:01:22";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:31:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:31:22', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:01:44";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:31:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:31:44', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:01:53";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:31:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:31:53', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:02:27";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:32:27", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:32:27', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:02:37";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:32:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:32:37', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:03:03";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:33:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:33:03', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:03:12";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:33:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:33:12', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:04:15";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:34:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:34:15', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:04:24";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:34:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:34:24', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:04:41";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 21:34:41", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 21:34:41', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:04:54";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:34:54", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:34:54', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:05:05";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:35:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:35:05', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:06:14";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 21:36:14", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 21:36:14', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765c6d1b25cc
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 21:34:41', '06765c6d1b25cc', '1', '0.00', '0', '0', '1', '950.00', '950', '950', '0', '1', '2024-12-20 21:36:14', '', '9', '0', 'نقدي', '1', '0', '3', '93', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','950','0','','0','0','950','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150502', '0', '2024-12-20 21:36:14', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '950', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 21:34:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35969;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('550','R3327', '150502', '1', '16277', '1', '650', '650', '0', '', '1', '2024-12-20 21:36:14', '16277', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35969-1,','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 550.00 , meanbuyprice = 549.00, lastbuyprice_withDiscount = 550.00, meanbuyprice_withDiscount = 547.00
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 548, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 549887;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16277, '2024-12-20', 650, 550, 550
                    , 549, 550, 547, 546.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 550, 548, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+549
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+547
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+546.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+548
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 650, 550, 550
                    , 549, 550, 547, 546.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 548, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+549
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+547
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+546.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+548
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '39', userid = '9', storedetaildate = '2024-12-20 21:36:14' WHERE storedetailid = '16276';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16277', '1', '1', '1', '150502', 'اضافة فاتورة مبيعات', 'sellbillController.php', '40', '39', '9', '2024-12-20 21:36:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35989;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('230','07244', '150502', '5', '16334', '1', '300', '300', '0', '', '1', '2024-12-20 21:36:14', '16334', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35989-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where sellbilldetailid = 549888;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16334, '2024-12-20', 300, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 300, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+230
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '9', storedetaildate = '2024-12-20 21:36:14' WHERE storedetailid = '16333';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16334', '1', '1', '1', '150502', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '9', '2024-12-20 21:36:14','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '9815',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8865','950', '0', '1', 'اضافة فاتورة مبيعات', '150502', '9815', '2024-12-20 21:36:14', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 93 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 950, 780, 780
                    , 779, 780, 777, 776.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,780, 778, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+779
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+777
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+776.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+780
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+778
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 950, 780, 780
                    , 779, 780, 777, 776.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,780, 778, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+779
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+777
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+776.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+780
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+778
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 950, 780, 780
                    , 779, 780, 777, 776.67, 780, 778)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+950, netSellCostBuyPrice = netSellCostBuyPrice+780
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+780
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+779
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+780
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+777
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+776.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+780
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+778;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765c6d1b25cc and sellbillId = 150502 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:06:15";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 21:36:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 21:36:15', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:06:50";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 21:36:50", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 21:36:50', '9', 'addAndRetuen', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06765c72fd5b18
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-20 21:36:15', '06765c72fd5b18', '1', '0.00', '0', '0', '1', '400.00', '400', '400', '0', '1', '2024-12-20 21:36:50', '', '9', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','400','0','','0','0','400','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-20','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','150503', '0', '2024-12-20 21:36:50', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-20 21:36:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36003;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36052;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07220', '150503', '5', '16293', '2', '200', '400', '0', '', '1', '2024-12-20 21:36:51', '16293', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36003-1,36052-1,','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 549889;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16293, '2024-12-20', 400, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '29', userid = '9', storedetaildate = '2024-12-20 21:36:51' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '2', '1', '150503', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31', '29', '9', '2024-12-20 21:36:51','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '10215',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('9815','400', '0', '1', 'اضافة فاتورة مبيعات', '150503', '10215', '2024-12-20 21:36:51', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-20', 400, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-20', 400, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 400, 310, 310
                    , 310, 310, 310, 310, 310, 310)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+400, netSellCostBuyPrice = netSellCostBuyPrice+310
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+310
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+310
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+310
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+310
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+310
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+310
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+310;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06765c72fd5b18 and sellbillId = 150503 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:06:51";
UPDATE user SET loginip = "192.168.1.33", lastactivetime = "2024-12-20 21:36:51", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 21:36:51', '9', 'addsellBill', '192.168.1.33', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:06:59";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:36:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:36:59', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:07:02";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:37:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:37:02', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:07:25";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:37:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:37:25', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:09:46";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:39:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:39:46', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:09:58";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:39:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:39:58', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:10:07";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:40:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:40:07', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:11:13";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:41:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:41:13', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:11:22";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:41:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:41:22', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:12:55";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:42:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:42:55', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:15:24";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:45:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:45:24', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:16:09";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:46:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:46:09', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:16:34";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:46:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:46:34', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:16:43";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:46:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:46:43', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:16:52";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:46:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:46:52', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:18:01";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:48:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:48:01', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:18:13";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:48:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-20 21:48:13', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:19:12";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:49:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 21:49:12', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:19:23";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:49:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 21:49:23', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:21:49";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:51:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 21:51:49', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:22:12";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:52:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 21:52:13', '2', 'add', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=add');
BEGIN;
INSERT INTO transfermoney (saveidfrom, saveidto, transfermoneyvalue, transfermoneydate, userid, conditions, dailyentryid , comment,currencyId,conversionFactor,conversionFactorFrom,conversionFactorTo,transfermoneyvalueInCurrency) VALUES ('2','16', '96000', '2024-12-20', '2', '0', '0','','1','1','0','0','96000');
UPDATE save SET  savecurrentvalue = '82595.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('178595.50','96000', '1', '2', 'تحويل امول الى الخزنة  [ دفعات اسبوعيه ] ', '3541', '82595.5', '2024-12-20 21:52:13', '2',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '576000',  userid = '2' WHERE saveid = '16';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('480000.00','96000', '0', '16', 'تحويل امول من الخزنة  [ فودافون كاش ] ', '3541', '576000', '2024-12-20 21:52:13', '2',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '2', saveidto = '16', transfermoneyvalue = '96000.00', transfermoneydate = '2024-12-20', userid = '2', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='96000' WHERE transfermoneyid = '3541';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:22:13";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:52:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 21:52:13', '2', 'sucess', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:22:15";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:52:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 21:52:15', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:22:18";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:52:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 21:52:18', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:22:37";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:52:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 21:52:37', '2', 'add', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=add');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid,expensenumbrt,expenseprice,expensetotaln,expenseshortfalls,supplier,suppRemainingVal,sellbillid,clientid,realestateid,realestateunitid,file,taxPer,taxVal,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,travelOfficeId,webApiId) VALUES ('1', 'نسبة تحويل و سحب', '', '213', '2024-12-20', '2', '0','-1','2','0','0','0','','0','0','0','0','0','0','0','0','0','0','0','.','0','0','0','0','0','0','0','0','0','0');
UPDATE save SET  savecurrentvalue = '82382.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('82595.50','213', '1', '2', 'إضافة مصروف', '25919', '82382.5', '2024-12-20 21:52:37', '2',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'نسبة تحويل و سحب', expensesdetails = '', expensesValue = '213.00', expensesdate = '2024-12-20', userid = '2', conditions = '0',saveid = '2' , dailyentryid = '0', bankid = '0', bankaccountid = '0', checknum = '', productid = '0', expensenumbrt = '0', expenseprice = '0', expensetotaln = '0', expenseshortfalls = '0',supplier='0',suppRemainingVal='0',sellbillid='0',clientid='0',realestateid='0',realestateunitid='0',file='.',taxPer='0',taxVal='0',travelDriverId='0',travelBusId='0',travelPathId='0',travelTripId='0',travelTripTypeId='0',travelTripDateId='0',travelOfficeId='0',webApiId='0' WHERE expensesid = '25919';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:22:38";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:52:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 21:52:38', '2', 'sucess', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:22:39";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:52:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 21:52:39', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:22:41";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:52:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 21:52:41', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:22:44";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:52:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 21:52:44', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:22:47";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:52:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 21:52:48', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:24:37";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:54:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 21:54:37', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:29:29";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 21:59:29", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 21:59:29', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:30:57";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:00:57", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 22:00:57', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:31:06";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:01:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-20 22:01:06', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:41:57";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:11:57", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 22:11:57', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:43:37";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:13:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 22:13:37', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:43:47";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:13:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 22:13:47', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:44:05";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:14:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 22:14:05', '2', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150375');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:45:18";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:15:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-20 22:15:18', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:46:16";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:16:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-20 22:16:16', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:57:46";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:27:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 22:27:46', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:58:19";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:28:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-20 22:28:19', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:58:38";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:28:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-20 22:28:38', '2', 'add', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =1797
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1797,@clientdebt,@clientname,@treeIdis);
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1797','-1830.00','1830','0','تسوية عجز عميل بالزيادة','-1', '0', '2024-12-20 22:28:38', '2', 'clientDeficitController.php', '', '1830', '0', null, '0', null, null,'', '0','1','1','1830','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-20', userid = '2' WHERE clientid = '1797';
UPDATE client SET  inUse = 0 where clientid = 1797;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =1797 ,id=248122
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:58:39";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:28:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-20 22:28:39', '2', 'sucess', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:58:40";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:28:40", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-20 22:28:40', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:58:44";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:28:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-20 22:28:44', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:59:13";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:29:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 22:29:13', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:59:26";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:29:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 22:29:26', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:59:37";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:29:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-20 22:29:37', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 18:59:41";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:29:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-20 22:29:41', '2', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=148722');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-20 19:01:38";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-20 22:31:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-20 22:31:38', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE userid = 2;
